Embedding framework in iOS generates an error when signing - ios

I am currently trying to embed the Azure client framework into an iOS project, but the build is failing when it tries to sign the framework, with the following error:
~/Library/Developer/Xcode/DerivedData/MyProject-gtoxtgdnkyheledfgmjhogvasnql/Build/Products/Debug-iphonesimulator/MyProject.app/Frameworks/AZSClient.framework: bundle format unrecognized, invalid, or unsuitable
After poking around on the web, I found this highly useful page:
https://github.com/mattgallagher/CwlSignal/issues/16
The command being run by code sign is this:
/usr/bin/codesign --force --sign - --timestamp=none \
--preserve-metadata=identifier,entitlements,flags \
~/Library/Developer/Xcode/DerivedData/MyProject-gtoxtgdnkyheledfgmjhogvasnql/Build/Products/Debug-iphonesimulator/MyProject.app/Frameworks/AZSClient.framework
which generates the error I mentioned above. Following Mat's lead and modifying the end of the command to point to the actual framework binary as follows:
/usr/bin/codesign --force --sign - --timestamp=none \
--preserve-metadata=identifier,entitlements,flags \
~/Library/Developer/Xcode/DerivedData/MyProject-gtoxtgdnkyheledfgmjhogvasnql/Build/Products/Debug-iphonesimulator/MyProject.app/Frameworks/AZSClient.framework/AZSClient
the command correctly executes and signs the framework.
My Question:
How do I modify the Xcode build system to do this. If I try just building after running the code sign on the command line, it overwrites my code sign. If I try building without signing the framework, it presents an unsigned version of the framework to the target (in this case the simulator).

Related

How can I adhoc-sign a library?

Trying to run an executable linking to a dynamic library, I get the following error:
Library not loaded:
[...]
Reason: tried:
<lib> not valid for use in process: mapped file has no
cdhash, completely unsigned? Code has to be at least ad-hoc signed.
How can I ad-hoc sign my lib?
First, you can confirm that your library is not signed with:
% codesign -d -v <lib>
Which should say:
<lib>: code object is not signed at all
Ad-hoc sign it with:
% codesign -s - <lib>
Although not advised for a production system, you can bypass the checks with these two build flags.
See Xcode project target settings, Signing and Capabilities,
then clean and rebuild

/usr/bin/codesign --force --sign with xcode 9 automatic code signing

Automatic signing configured with Xcode9 working fine with machine but giving below error when I access that machine remotely via ssh & run through commandline bash scripts which is using Xcodebuild with Automatic code sign style or if same code base is configured with jenkins pipeline & triggered a run still give below error message:-
/usr/bin/codesign --force --sign A7F8FCD694D7923A3E57826398C3380E2E5A5446 --entitlements unknown error -1=ffffffffffffffff
Command /usr/bin/codesign failed with exit code 1
not able to understand what is wrong while automatic signing is working with one machine so it should work when somebody try to run remotely as well.

Adding UserNotifications.framework causes codesign -1 error (Xcode 8)

I'll start with just the error,
/usr/bin/codesign --force --sign <keyremoved> --preserve-metadata=identifier,entitlements --timestamp=none /Users/charlesgeorge/Library/Developer/Xcode/DerivedData/Unity-iPhone-cvqmwrcjxssykmdqdwkfdmzbtrxc/Build/Intermediates/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/Lucktastic.app/Frameworks/UserNotifications.framework
/Users/charlesgeorge/Library/Developer/Xcode/DerivedData/Unity-iPhone-cvqmwrcjxssykmdqdwkfdmzbtrxc/Build/Intermediates/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/Lucktastic.app/Frameworks/UserNotifications.framework: bundle format unrecognized, invalid, or unsuitable
Command /usr/bin/codesign failed with exit code 1
This only occurs on Archive. Running on my phone loads correctly.
Things I've tried so far.
Delete Derived Data, clean, clean build-> same issue
Changing to managed provisioning
Nada
The culprit seems to be UserNotifications.framework.
If I set it as a linked framework, it will build, but when I run it on iOS I get an error on iOS9. I've embedded the binary instead, and that gets things to run okay, but that starts the codesigning issues. This is the setup
http://screencast.com/t/89eoG82gdjW
Any ideas on why that won't codesign properly, or how to link framework correctly with iOS 9?
Okay,
After working for a while. The issue is that I shouldn't have even been including that framework. I just need to flip the "Uses Push Notifications" to get it working, and remove all references to the UserNotifications.framework.

Xcode 5 continuous integration CodeSign fail

Hi there.
I'm trying to configure continuous integration for my iOS app with xcode 5 and OS X Server. I added certificates and p12 to system KeyChain, I also copied provisioning profiles to server folder for profiles.
Integration fails and log shows error message
Short message:
Command /usr/bin/codesign failed with exit code 1
Full message:
CodeSign
/Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/InstallationBuildProductsLocation/Applications/MomentSeller.app
cd /Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/source/Moment
setenv CODESIGN_ALLOCATE /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Using code signing identity "iPhone Distribution: Company Name. (ZX6C5SJYP9)" and provisioning profile "Moment Seller Production"
(E6FC8157-98F3-4A28-BFF3-36EFA6334019)
codesign --force --sign C2F81E886780437B90630A748111D3340DC8EFC8 --resource-rules=/Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/InstallationBuildProductsLocation/Applications/MomentSeller.app/ResourceRules.plist
--entitlements /Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/IntermediateBuildFilesPath/Moment.build/Release-iphoneos/MomentSeller.build/MomentSeller.xcent
/Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/InstallationBuildProductsLocation/Applications/MomentSeller.app
/Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/InstallationBuildProductsLocation/Applications/MomentSeller.app:
User interaction is not allowed. Command /usr/bin/codesign failed with
exit code 1
** ARCHIVE FAILED **
The following build commands failed: CodeSign
/Library/Server/Xcode/Data/BotRuns/Cache/c60acccd-d128-d128-b0e3-070a65bdd9dc/DerivedData/Build/Intermediates/ArchiveIntermediates/MomentSeller/InstallationBuildProductsLocation/Applications/MomentSeller.app
(1 failure)
Any ideas?
Thanks.
I've run into this problem myself. This blog helped me out. http://matt.vlasach.com/xcode-bots-hosted-git-repositories-and-automated-testflight-builds/
As posted by Dominik Kroutvar:
User interaction is not allowed. Command /usr/bin/codesign failed with
exit code 1
This error happens when the following setting is not made manually. As
described in one of the posts above you have to put the mobileprofile
for code signing in the system keychain. The certificate is called
iPhone Distribution:. This distribution certificate must have a
private key! Open the Settings dialog either by double click on the
private key or through the context menu>Get Info. Then go to Access
control and put /usr/bin/codesign in the table. This allows the
codesign application to sign your built application. After that
everything should work without the meaningless codesign error exit
code 1.
As already stated you simply need to run security -v unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN".
Run this before the build and the codesign succeeds.

How is code signing done in Xcode 4.5

I have a script for building my app that is broken since updating to Xcode 4.5. The problem is code signing. When I run the following:
/usr/bin/xcrun \
-sdk iphoneos \
PackageApplication \
-v "${BUILD_DIR}/${APPLICATION_NAME}.app" \
-o "${APP_ARCHIVE}" \
--sign "${DEVELOPER_ID}"
--embed "${PROVISIONING_PROFILE}"
I get the following error:
error: /usr/bin/codesign --force --preserve-metadata --sign iPhone Developer: Apple Developer --resource-rules=/var/folders/p5/gfgpv6911ylbs52cnbh2___m0000gq/T/ky9_XtRlRr/Payload/Blah.app/ResourceRules.plist /var/folders/p5/gfgpv6911ylbs52cnbh2___m0000gq/T/ky9_XtRlRr/Payload/Blah.app failed with error 1. Output: /var/folders/p5/gfgpv6911ylbs52cnbh2___m0000gq/T/ky9_XtRlRr/Payload/Blah.app: replacing existing signature
codesign_allocate: object: /private/var/folders/p5/gfgpv6911ylbs52cnbh2___m0000gq/T/ky9_XtRlRr/Payload/Blah.app/Blah malformed object (unknown load command 34)
/var/folders/p5/gfgpv6911ylbs52cnbh2___m0000gq/T/ky9_XtRlRr/Payload/Blah.app: object file format unrecognized, invalid, or unsuitable
Something is going wrong with the code signing where it was working fine with Xcode 4.3 before. Can code signing still be done with the same command? Is this "unknown load command" the culprit, and if so, what is it, and how would one go about finding and fixing it?
It turns out upgrading XCode from App Store does NOT automatically upgrade everything.
Go to Preferences / Downloads and make sure the latest Command Line Tools are installed.
And once you update the cmd restart your mac for better results, I wasted 1 hour on this.

Resources