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.

Şafak Gezer
  • 3,928
  • 3
  • 47
  • 49
  • 4
    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 -o --sign --embed `. With Xcode 6.0.1, it all worked OK. – Daniel Martín Oct 22 '14 at 07:09

7 Answers7

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

Community
  • 1
  • 1
Tim
  • 14,447
  • 6
  • 40
  • 63
  • 7
    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) – Şafak Gezer Oct 22 '14 at 10:48
  • 10
    CODE_SIGN_RESOURCE_RULES_PATH is the variable name if you're editing your xcodeproj settings through a script or command line. https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/Articles/Getting%20Information%20on%20a%20Build%20Setting.html#//apple_ref/doc/uid/TP40010155-CH6-SW1 – roblocop Oct 23 '14 at 23:46
  • 5
    I can't see `Code Signing Resource Rules Path` in my Build Settings. Any idea? – Georg Oct 27 '14 at 12:22
  • 7
    Make sure you selected ALL and not BASIC settings (The row below "General, Capabilities, Info, Build Settings etc") – A.S. Oct 27 '14 at 14:04
  • Apparently this will get your app rejected: http://stackoverflow.com/questions/26488077/ios-ipa-codesign-on-xcode-6-1-yosemite/26489412#26489412 – Glenn Maynard Dec 01 '14 at 15:48
  • @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! – Tim Dec 02 '14 at 03:42
  • @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. – Gian Franco Zabarino Nov 10 '15 at 20:25
  • Your app will be rejected according to Apple: https://developer.apple.com/library/mac/technotes/tn2206/_index.html#//apple_ref/doc/uid/DTS40007919-CH1-TNTAG205 – Gustavo Barbosa Jun 14 '16 at 19:55
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});
Alistra
  • 5,177
  • 2
  • 30
  • 42
  • Removed the rogue deprecated parameter from PackageApplication, and buildozer now builds my Python app for iOS – Ian Ellis Nov 23 '14 at 21:35
  • 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 :) – Pellet Nov 25 '14 at 06:19
  • @IanEllis: Could you please let me know how did you remove the "resource-rules" parameter from PackageApplication. It will be of great help!! – Rashmi Ranjan mallick Jan 05 '15 at 14:22
  • 8
    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: https://bitbucket.org/WeWantToKnow/xcode_scripts/raw/4d252906062afc00f3c61e534b2c7810288bf0f1/xcode_fix_PackageApplicationResourceRules.sh to use: xcode_fix_PackageApplicationResourceRules.sh /Applications/Xcode6.1.1.app – coffeebreaks Jan 06 '15 at 10:52
  • This is the correct answer. The build setting answer forces use of a deprecated API. – Jameson Mar 27 '15 at 21:31
  • I just installed Xcode 6.4, and SURPRISE!, SURPRISE!, this issue is STILL NOT FIXED. I had to reapply the diff from a above. – JimClarke Jul 01 '15 at 18:23
  • The above worked for this problem. Then there was the 'Invalid Swift support' email from iTunesConnect. as noted [here](http://faq.sealedabstract.com/xcodeCI/#the-case-of-the-missing-swiftsupport) and in the [Apple Dev Forum](https://devforums.apple.com/thread/245492?start=25&tstart=0). I ended up using the script from [bq](https://github.com/bq/ipa-packager). – skitheo Aug 18 '15 at 22:19
  • This is ridiculous, Apple common. Start supporting continuous integration NOW. – jimpic Sep 17 '15 at 07:10
  • Thank you @Alistra and @coffeebreaks! I now have that xcode_fix script in my personal bin directory. – bmauter Nov 03 '15 at 17:11
  • FWIW - I just used this for XCode 8.2.1 and Bamboo XCode plugin integration. It worked great. – Nick N Dec 20 '16 at 19:45
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.

Adam
  • 4,405
  • 16
  • 23
  • 1
    It worked for me to just make the .ipa with Xcode, and upload via the desktop app. – livingtech Oct 22 '14 at 20:04
  • @livingtech 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. – helmesjo Dec 18 '14 at 12:49
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.

Community
  • 1
  • 1
Vladimir Grigorov
  • 10,903
  • 8
  • 60
  • 70
  • thanks Vladimir, I was getting really confused on this with how it conflicts with Xcode 7 submissions. – kevinl Sep 22 '15 at 18:04
  • how exactly do you replace xcrun? I can't see any settings for that in Jenkins Xcode plugin :( – Hlung Sep 24 '15 at 04:31
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

GrumpyGary
  • 201
  • 2
  • 6
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.

Community
  • 1
  • 1
gbitaudeau
  • 2,207
  • 1
  • 17
  • 13
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.

Community
  • 1
  • 1
pr1001
  • 21,727
  • 17
  • 79
  • 125