How to fix Xcode 6.1 error while building IPA

IosXcodeBuildCode SigningIpa

Ios Problem Overview


Just upgraded to Xcode 6.1 today, and guess what: Now I'm having trouble submitting builds using the TestFlight desktop app. Here's the error I'm getting while the app starts building the IPA:

The error

> error: /usr/bin/codesign --force > --preserve-metadata=identifier,entitlements,resource-rules --sign 854059d45eed724593debef577a562e1ba96ab55 > --resource-rules=/tmp/QYFSJIvu7W/Payload/XX.app/ResourceRules.plist > /tmp/QYFSJIvu7W/Payload/XX.app failed with error 1. Output: > Warning: usage of --preserve-metadata with option "resource-rules" > (deprecated in Mac OS X >= 10.10)! Warning: --resource-rules has been > deprecated in Mac OS X >= 10.10! > /tmp/QYFSJIvu7W/Payload/XX.app/ResourceRules.plist: cannot read > resources

The 'Support Article' has no idea what is going on.

It does not seem to be a TestFlight problem because the same thing happens in a CI environment like Jenkins using the xcrun or similar tools.

The app wasn't updated for months, so I know that I shouldn't be expecting for any updates to fix this anytime soon. It used to work really well for me and my clients so I'm not really keen on abandoning it for something else either.

Any ideas for what this error is about, and how to fix it would be very appreciated.

Ios Solutions


Solution 1 - Ios

I wish I knew why it works, but here's a fix that worked for me:

> Found the fix ! > > Click on your project > Targets > Select your target > Build Settings > > > > Code Signing Resource Rules Path > > and add : > > $(SDKROOT)/ResourceRules.plist

Solution 2 - Ios

The following patch for PackageApplications fixed it for me, I removed resource-rules as it says it's deprecated on 10.10.

Testflight builds work without it. Appstore builds too.

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
 % diff PackageApplication PackageApplicationFixed 
155,157c155,156
<     my @codesign_args = ("/usr/bin/codesign", "--force", "--preserve-metadata=identifier,entitlements,resource-rules",
<                          "--sign", $opt{sign},
<                          "--resource-rules=$destApp/ResourceRules.plist");
---
>     my @codesign_args = ("/usr/bin/codesign", "--force", "--preserve-metadata=identifier,entitlements",
>                          "--sign", $opt{sign});

Solution 3 - Ios

I emailed TestFlight support and got this response:

> Our team is currently investigating this issue with the TestFlight Desktop app. In the meantime, please use Xcode to create the IPA file and then upload it using the desktop app or the TestFlight website.

The suggested workaround did work.

Solution 4 - Ios

The answer by Tim Gostony no longer works since the release of Xcode 7. Now the App Store submission process fails when resource rules are present. The solution is to clear your Code Signing Resource Rules Path and replace xcrun with xcodebuild tool:

xcodebuild -exportArchive -archivePath [path to archive] -exportPath [path to output directory] -exportOptionsPlist [path to options.plist file]

The simplest Options.plist for exporting ad-hoc distribution ipa files looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>iCloudContainerEnvironment</key>
	<string>Production</string>
    <key>teamID</key>
    <string>[YOUR TEAM ID]</string>
    <key>method</key>
    <string>ad-hoc</string>
</dict>
</plist>

There are other options available for this plist file regarding bitcode, app thinning, etc. That's why I think xcodebuild tool is the right tool for exporting ipa files for iOS 9 and above.

More details about options plist are available with xcodebuild -help command.

Solution 5 - Ios

On Yosemite w/ XCode 6.4 even using the SDKROOT patch the codesigning fails. The following article explains how to patch the XCode script to get around this. Note that this is patching XCode, so it is version specific, but fixes the problem.

http://www.jayway.com/2015/05/21/fixing-your-ios-build-scripts

Solution 6 - Ios

The answer from Alistra work for me but I doesn't want to change a script which is not mine (a future Xcode release might change this file and the correction will be lost).

> diff PackageApplication PackageApplicationFixed 155,157c155,156 <- my @codesign_args = ("/usr/bin/codesign", "--force", "--preserve-metadata=identifier,entitlements,resource-rules", <- "--sign", $opt{sign}, <- "--resource-rules=$destApp/ResourceRules.plist"); --- -> my @codesign_args = ("/usr/bin/codesign", "--force", "--preserve-metadata=identifier,entitlements", -> "--sign", $opt{sign});

I think answer from Vladimir Grigorov is the best if you have an archive using :

> xcodebuild -exportArchive -archivePath [path to archive] -exportPath [path to output directory] -exportOptionsPlist [path to options.plist file]

In my case, I doesn't have the archive, because I modify the application after build it and I need to change the Bundle Id and signing certificate.

The solution I found is to call codesign myself before used PackageApplication and ask PackageApplication to not sign. Like this :

replace :

 /usr/bin/xcrun -sdk iphoneos PackageApplication -v "<app_path>" -o "<ipa_path>" --sign "<provisioning_profile.certificateSubject>" --embed "<provisioning_profile.path>"

by :

/bin/cp -rpfv "<provisioning_profile.path>" "<app_path>/embedded.mobileprovision"
/usr/bin/codesign -v -vvvv -f -s "<provisioning_profile.certificateSubject>" --entitlements="<entitlement_path>" "<app_path>"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "<app_path>" -o "<ipa_path>"

Don't forget to embedded the .mobileprovision file using to sign with cp.

Solution 7 - Ios

As specified in another answer, you can also just not specify the distribution certificate to sign with and it will package correctly. TestFlight would need to update their app to do this.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionŞafak GezerView Question on Stackoverflow
Solution 1 - IosTimView Answer on Stackoverflow
Solution 2 - IosAlistraView Answer on Stackoverflow
Solution 3 - IosAdamView Answer on Stackoverflow
Solution 4 - IosVladimir GrigorovView Answer on Stackoverflow
Solution 5 - IosGrumpyGaryView Answer on Stackoverflow
Solution 6 - IosgbitaudeauView Answer on Stackoverflow
Solution 7 - Iospr1001View Answer on Stackoverflow