Jenkins vs. Xcode plugin - codesign troubles - xcode

I have updated to OS X Yosemite and also Xcode 6.1 (downloaded from the developer site), from this time I have had the problem with the building as in the log file I see the note "Warning: --resource-rules has been deprecated in Mac OS X >= 10.10!". Does someone know how to use Xcode plugin without "resource-rules" flag? Thank you.

Everything is ok with Jenkins plugin. Just product settings is incorrect.
Open the "Build Settings" tab of your project. Searched "Code Signing Resource Rules Path", it was empty for me. Change to: $(SDKROOT)/ResourceRules.plist
credits goes to Adams Blair who described this problem with SDK2.2
https://stackoverflow.com/a/7919137/2124345
Update
This solution doesn't remove the warning itself. But i'm pretty sure that warning isn't a problem. The problem is that without this setting ResourceRules.plist files isn't generated in Payload folder, and build process stops because file is missing.
And again, it's not related with jenkins plugin at all. Same error happens with xcrun -sdk iphoneos PackageApplication. Jenkins just calling this command line as a build step.

The answer provided by Julius Lisauskas will resolve the warning, but it is actually just a workaround for a bug that exists in the Jenkins Xcode plugin xcrun.
As mentioned in Apple Technical Note TN2206:
Systems before OS X Mavericks documented a signing feature
(--resource-rules) to control which files in a bundle should be sealed
by a code signature. This feature has been obsoleted for Mavericks.
Code signatures made in Mavericks and later always seal all files in a
bundle; there is no need to specify this explicitly any more. This
also means that the Code Signing Resource Rules Path build setting in
Xcode should no longer be used and should be left blank.
It is thus no longer possible to exclude parts of a bundle from the
signature. Bundles should be treated as read-only once they have been
signed.
There is an issue raised on the Jenkins Xcode plugin regarding this bug that concludes the bug lies in Xcrun.

As specified in another answer, you can also just not specify the distribution certificate to sign with and it will package correctly.

Related

Error Compiling Publish (Sundell) from Manifest File

TLDR;
I installed John Sundell's Publish according to the accepted practices and immediately get an error when I try to build my site package. How do I successfully install the product?
After cloning the publish package:
git clone https://github.com/JohnSundell/Publish.git
I cd'd into the Publish folder and ran:
make
which created an executable at /usr/local/bin/publish
I opened a new terminal window, created a directory using mkdir Saturday and then cd'd into that folder. I typed publish new and was successful:
✅ Generated website project for 'Saturday'
Run 'open Package.swift' to open it and start building
When I open the manifest file (Package.swift) and type cmd-S (Save) it imports all the necessary packages, and everything looks good to go.
When I type cmd-B (Build), however this error message comes up:
The package product 'CollectionConcurrencyKit' requires minimum platform version 13.0 for the iOS platform, but this target supports 11.0
When I look at the clone/install of Publish I see:
Computing version for https://github.com/johnsundell/collectionConcurrencyKit.git
Computed https://github.com/johnsundell/collectionConcurrencyKit.git at 0.1.0 (0.37s)
Notice it says version 0.1.0. In the generated package for my site, it retrieves version 0.2.0. I don't know if that's an issue.
But not one other Package.swift file in all the fetched dependencies mentions iOS.
I have this line in my Package.swift
platforms: [.macOS(.v12)],
So I know I haven't added this dependency on iOS inadvertently, so I don't understand the error message.
I'm running macOS Monterey 12.6 on Xcode 14.0 (14A309) - both are the most recent release versions available.
The hardware is: MacBook Pro (16-inch, 2021) using the Apple M1 Pro chip
If I'm leaving anything out, please comment and I'll provide more detail.
This is a slap your forehead 🤦🏽‍♂️ kind of thing here.
It turns out that when I opened the Package.swift it defaulted to an iOS scheme that I had just been using. I updated the scheme to a macOS based one, the problem went away. Now I understand the source of the iOS error. Apparently the two versions of ConcurrencyKit is a red herring.
Hope this helps others! Always check your target when compiling.

Xcode 11.2.1 - Command CodeSign failed with a nonzero exit code

I'm working on a SFML app for macOS with the latest Xcode version.
I got a "Command CodeSign failed with a nonzero exit code" error when it tries to sign the SFML frameworks. I added these under "Link Binary with Libraries" and "Copy Files" in Target, under Build Phases. Before, I was working with my local frameworks under /Library/Frameworks, and it was working very well.
Now I need to create an archive .app.
I've tried a lot of things seen on other posts here (like lock and unlock my keychains), but nothing worked. Still got that error.
My SFML Frameworks in "Link Binary with Libraries"
/Users/lounesksouri/Library/Developer/Xcode/DerivedData/Squadro-gqwjbvsooypqaifxxyzhdrahkdpo/Build/Intermediates.noindex/ArchiveIntermediates/Squadro/InstallationBuildProductsLocation/Applications/Squadro.app/Contents/Frameworks/sfml-system.framework/Versions/A: bundle format unrecognized, invalid, or unsuitable
Command CodeSign failed with a nonzero exit code
Ok, I solved my problem, after long hours.
It's a lot more simple to use the script already present in Build Phases tab, generated if you use the SFML App Xcode template (see here the original script). I had tried it at first, but it didn't work so I let it down.
But, in this script, the first three lines are not the good ones, for a normal SFML installation on macOS. We need to modify these lines with the good paths to the Frameworks and lib folders, as follows :
SFML_DEPENDENCIES_INSTALL_PREFIX="/Library/Frameworks"
CMAKE_INSTALL_FRAMEWORK_PREFIX="/Library/Frameworks"
CMAKE_INSTALL_LIB_PREFIX="/usr/local/lib"
FRAMEWORKS_FULL_PATH="$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/"
Secondly, there is still the code signing problem : the archive will created but we will get an error if we start the .app. The solution to this problem is to check Disable Library Validation under Target/Signing & Capabilities to allow the application to load plug-ins or frameworks signed by other developers.
Finally, if we create the archive and launch the application, everything goes normally, as planned.
I faced this problem with the new update of Xcode. I was reading your discussion, and did some accidental modifications. I am definetely not an expert but what I did fixed the problem so I did not receive tgis error anymore. So I added the sfml libraries (5 libraries), whose paths are written in build settings -> framework swarch paths. And this adding automatically added them in Embedded Frameworks under the Build phases section. What I did is unchecking the checkboxes of all 5 libraries "Code sign On copy". Thank you guys for giving me the path for "solving" the problem :))))
For the Code-signing issue:
Open a Terminal,
Go to the Framework folder (cd /Library/Frameworks) and sing them.
choose your identity
security find-identity -vp codesigning
sign them Frameworks!
codesign -s AD90FAFAFAFAFAFAFAF-YOURHASH-9D6 ogg.framework
codesign ... all the others
run and enjoy!

Create custom Platform and SDK for Xcode 8.3+

I'm trying to create a custom .platform and SDK in Xcode 8.3 and higher.
I am ultimately attempting to update the old DarwinBuild build system so that I can compile a few of the Apple open source components. DarwinBuild used to use this technique in order to be able to compile against a different set of headers and libraries without having to chroot.
DarwinBuild includes a setup script, installXcode32, that creates a new .platform under Xcode's Developer/Platforms directory, and a new sdk under the platform's Developer/SDKs directory. It also creates an Info.plist and SDKSettings.plist in the right spots. This script needs some updating to work with Xcode 8.3.
I know this is unsupported, but that doesn't matter in this case. After all, Apple published the original script...
I updated the original installXcode32 script to work with the new Xcode paths (/Applications/Xcode.app/Contents/...), and it produces the new .platform, Info.plist, and SDKSettings.plist, and they're all symlinked to the right spots. However, xcodebuild -showsdks now produces this error:
xcodebuild: error: Initialization failed.
Reason: Required content for platform darwin is missing.
I know it's an issue with the Info.plist and SDKSettings.plist files. I have tried copying the entire MacOSX.platform directory, and changing the names in the .plist, and I get the same error.
Does anyone know enough about Xcode and platforms to know what is required to get Xcode 8.3+ to recognize a "new" Platform and sdk?
Many thanks!
I have successfully done this with Xcode 9.4, pretty much like you did. I changed:
CanonicalName
PLATFORM_NAME
DisplayName

codesigning issues with multiple binaries on the same path

Ive been trying to create a build of my program signed with my mac developer ID but i keep getting the error message "Multiple binaries share the same codesign path". I have checked the code signatures on each of the attached frameworks using the codesign terminal ultity and there doesnt seem to be any codesigning issues.If it helps the frameworks which seem to causing the problem are SDL2, SDL2_image, SDL2_mixer and SDL2_ttf. Also i am running Xcode 6.1.1 on yosemite 10.10.2
Open your Archive folder and delete all previous built version before your code signing was made. Try again after.

How do you fix "code object is not signed at all In subcomponent:" in Xcode 6, Mac OS X Yosemite or Mavericks?

When compiling my application I'm getting the following error:
CodeSign /Users/pupeno/Library/Developer/Xcode/DerivedData/ProjectX-cynmgyozflnwbpamwnpsnhgshuyq/Build/Products/Debug/Project\ X.app
cd /Users/pupeno/Projects/ProjectX
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "Mac Developer: José Fernández (G4PM7K38JH)"
/usr/bin/codesign --force --sign A21FB31766DDCBB28FBB4E4DD86E3743024A45F3 --entitlements /Users/pupeno/Library/Developer/Xcode/DerivedData/ProjectX-cynmgyozflnwbpamwnpsnhgshuyq/Build/Intermediates/ProjectX.build/Debug/App.build/Project\ X.app.xcent --requirements =designated\ =>\ anchor\ apple\ generic\ \ and\ identifier\ \"$self.identifier\"\ and\ ((cert\ leaf[field.1.2.840.113635.100.6.1.9]\ exists)\ or\ (\ certificate\ 1[field.1.2.840.113635.100.6.2.6]\ exists\ and\ certificate\ leaf[field.1.2.840.113635.100.6.1.13]\ exists\ \ and\ certificate\ leaf[subject.OU]\ =\ \"XHT4M2DATL\"\ )) /Users/pupeno/Library/Developer/Xcode/DerivedData/ProjectX-cynmgyozflnwbpamwnpsnhgshuyq/Build/Products/Debug/Project\ X.app
/Users/pupeno/Library/Developer/Xcode/DerivedData/ProjectX-cynmgyozflnwbpamwnpsnhgshuyq/Build/Products/Debug/Project X.app: code object is not signed at all
In subcomponent: /Users/pupeno/Library/Developer/Xcode/DerivedData/ProjectX-cynmgyozflnwbpamwnpsnhgshuyq/Build/Products/Debug/Project X.app/Contents/Frameworks/Paddle.framework
Command /usr/bin/codesign failed with exit code 1
I'm using two frameworks, Paddle and Sparkle and they are configured to sign on copy:
Looking for a solution to this problem I found many recommendations to do a --deep sign, which is officially discouraged by Apple (Using the codesign Tool's --deep Option Correctly).
I also found the article Code Signing and Mavericks which also explains that using --deep is wrong and offers an alternative: using a script to generate signatures for each framework. I think this is something that was needed before Xcode had the option to sign on copy, but I gave it a try anyway. It made no difference, I still get the same error. Looking at the logs, the bundles are getting signed with the "Sign on copy" option, so, adding that script caused them to get signed twice.
My code signing identity is configured as follows for the whole project and each target just inherits it:
I understand that's not the appropriate signature for Release, but for now, we are just trying to get this to build and run locally.
Any ideas what's wrong? Any ideas how to fix it?
I understand that
For me I had to go to the Project build settings and set Other Code Signing Flags to --deep. The problem was that my framework in the project was not signed.
For All who still are facing this issue, Please make sure 'Product Name' in build setting matches with 'Executable file' set in info.plist.
Generally when we duplicate exiting code, we simply change either product name or Executable file, and this mismatched creates a issue.
The problem was that the Framework, Paddle.framework, became corrupt. The symlinks were resolved to the files they were pointed to, so, compilation worked just fine, but signing didn't.
Re-downloading the framework and copying it into the project fixed the problem.
For me the solution was to re-Add a resource folder (checking Create groups instead of create folder references).
Adding ANOTHER thing to check if you get this error:
In the Build Phases pane for your Project's application target, make sure the Embed Frameworks phase comes before the Link Binary With Libraries phase:
I'm running macOS 11.2.3 and Xcode 12.4.
An Aside:
It's utterly ridiculous how fragile and broken code-signing remains. It's 2021 and this post alone has 87 different "fixes" to solve the same damn error message. There's just no excuse for wasting developers' time like this. Fix your IDE, Apple.
For me this problem was resolved by a simple "clean build folder" action, keyboard shortcut: shift+option+command+K.
I'll admit codesigning is still a black art to me, but in Xcode 6 I found that removing all of my signing scripts (which were necessary in Xcode 5, along with --deep flags) and additional signing flags, and just using the "codesign on copy" option in the Framework's Copy Files phase of the build worked flawlessly for me.
For me, it turned out that I had inadvertently added a bash build script to the target. Making sure I had no sneaky scripts accidentally copied into the target fixed the issue.
Product -> Cleanup build folder
Build/Compile project
for me, one of the frameworks I was including, had another of the frameworks marked as "embed and sign"... which you can't do... only the app should be doing that.
marking the grandchild framework as "do not embed" in the child framework, removed this issue.
I faced this problem after adding fastlane to upload screenshots to App Store Connect automatically. I had to remove fastlane from the project and clean the build folder to make it work again.
Using CocoaPods in the project it helped me to go to the Pods project, select a problem framework and set the correct developemtn team on Signing & Capabilities page or Build settings with All levels set.
In my case I both had a subproject and a subproject of that subproject (i.e. a sub-subproject) to which I had added the same Swift package dependency. Keeping it in the sub-subproject and removing it from the subproject solved the issue.
As shown by the number of answers here the causes for the error can be many.
In my experience building a complex project with multiple level of Frameworks, Static libraries from Swift packages and Pods you should follow these rules:
A Framework can't embed and sign another framework: only and App can do that.
A Framework can use a static library (from a Swift Package for instance) but the library must be present only in the Framework and not in the main App. If the same library is embedded in both Framework and main App, in some unknown circumstances, this error occurs.
Be sure to clean the build folder after each change to frameworks and library structure/embed

Resources