How to fix Xcode 6.1 error while building IPA
Asked Answered
Z

7

140

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.

Zibet answered 21/10, 2014 at 23:6 Comment(1)
It does not seem to be a TestFlight problem because the same thing happens in a CI environment using the xcrun command like this: xcrun -sdk iphoneos PackageApplication -v <Path_to_App> -o <Path_to_IPA> --sign <Distribution_certificate> --embed <Provisioning_profile>. With Xcode 6.0.1, it all worked OK.Lunseth
B
312

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

Burg answered 22/10, 2014 at 2:44 Comment(8)
Thanks! Frankly I don't care why it works :) just the latest in what Apple broke on their grand streak of screw-ups in the last couple of months. Anyway, thanks for pointing out to the solution. (and a downvote for me for not looking up the error thoroughly before posting)Branham
CODE_SIGN_RESOURCE_RULES_PATH is the variable name if you're editing your xcodeproj settings through a script or command line. developer.apple.com/library/ios/recipes/…Leclair
I can't see Code Signing Resource Rules Path in my Build Settings. Any idea?Tube
Make sure you selected ALL and not BASIC settings (The row below "General, Capabilities, Info, Build Settings etc")Agglutinative
Apparently this will get your app rejected: #26488577Scrip
@GlennMaynard As far as I can tell, that person's app got rejected on the Mac App Store, while the question/answer here is specific to TestFlight on iOS. I can't find anything saying that iOS apps are getting rejected for the ResourceRules.plist reason, but would love any links to more information about these rejections!Burg
@Alistra's answer works for me, and it removes deprecated options from being executed. I just edited it by hand with TextWrangler and worked like a charm.Weiland
Your app will be rejected according to Apple: developer.apple.com/library/mac/technotes/tn2206/_index.html#//…Spurgeon
M
61

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});
Monro answered 31/10, 2014 at 12:22 Comment(10)
Removed the rogue deprecated parameter from PackageApplication, and buildozer now builds my Python app for iOSCorydalis
Great fix! Thanks alot :) The above "Code Signing Resource Rules Path" setting did not fix my problem but this answer did, plus the fix is now global across all projects :)Yun
@IanEllis: Could you please let me know how did you remove the "resource-rules" parameter from PackageApplication. It will be of great help!!Anabal
Here's a oneliner to fix PackageApplication: perl -p -i'Orig' -e 'BEGIN{undef $/;} s/,resource-rules(.*sign}).*ResourceRules.plist"/$1/smg' "/Applications/Xcode6.1.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication" (adjust your path) And a full script to apply this: bitbucket.org/WeWantToKnow/xcode_scripts/raw/… to use: xcode_fix_PackageApplicationResourceRules.sh /Applications/Xcode6.1.1.appGranada
This is the correct answer. The build setting answer forces use of a deprecated API.Jamarjamb
I just installed Xcode 6.4, and SURPRISE!, SURPRISE!, this issue is STILL NOT FIXED. I had to reapply the diff from a above.Pawnbroker
The above worked for this problem. Then there was the 'Invalid Swift support' email from iTunesConnect. as noted here and in the Apple Dev Forum. I ended up using the script from bq.Seizing
This is ridiculous, Apple common. Start supporting continuous integration NOW.Hunch
Thank you @Monro and @coffeebreaks! I now have that xcode_fix script in my personal bin directory.Gnome
FWIW - I just used this for XCode 8.2.1 and Bamboo XCode plugin integration. It worked great.Epiphragm
P
10

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.

Peirce answered 22/10, 2014 at 0:56 Comment(2)
It worked for me to just make the .ipa with Xcode, and upload via the desktop app.Demetricedemetris
@Demetricedemetris Yeah, however I also got the dreaded "Xcode generating a new profile instead of choosing the one I want it to"-bug :) Uploading with testflight directly worked splendid.Glasper
T
10

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.

Towill answered 16/9, 2015 at 11:57 Comment(2)
thanks Vladimir, I was getting really confused on this with how it conflicts with Xcode 7 submissions.Ilke
how exactly do you replace xcrun? I can't see any settings for that in Jenkins Xcode plugin :(Coltin
S
3

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

Success answered 30/7, 2015 at 15:37 Comment(0)
S
2

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.

Shifra answered 2/12, 2015 at 15:57 Comment(0)
A
1

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.

Arianaariane answered 29/10, 2014 at 19:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.