How to fix Xcode 6.1 error while building IPA

40,334

Solution 1

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

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

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 4

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 5

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

Share:
40,334
Şafak Gezer
Author by

Şafak Gezer

Independent software engineer, Istanbul.

Updated on June 30, 2021

Comments

  • Şafak Gezer
    Şafak Gezer almost 3 years

    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
    Şafak Gezer over 9 years
    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)
  • lothorp
    lothorp over 9 years
    It worked for me to just make the .ipa with Xcode, and upload via the desktop app.
  • roblocop
    roblocop over 9 years
    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/…
  • Georg
    Georg over 9 years
    I can't see Code Signing Resource Rules Path in my Build Settings. Any idea?
  • A.S.
    A.S. over 9 years
    Make sure you selected ALL and not BASIC settings (The row below "General, Capabilities, Info, Build Settings etc")
  • Ian Ellis
    Ian Ellis over 9 years
    Removed the rogue deprecated parameter from PackageApplication, and buildozer now builds my Python app for iOS
  • Pellet
    Pellet over 9 years
    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 :)
  • Glenn Maynard
    Glenn Maynard over 9 years
    Apparently this will get your app rejected: stackoverflow.com/questions/26488077/…
  • Tim
    Tim over 9 years
    @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!
  • helmesjo
    helmesjo over 9 years
    @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.
  • Rashmi Ranjan mallick
    Rashmi Ranjan mallick over 9 years
    @IanEllis: Could you please let me know how did you remove the "resource-rules" parameter from PackageApplication. It will be of great help!!
  • coffeebreaks
    coffeebreaks over 9 years
    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/i‌​PhoneOS.platform/Dev‌​eloper/usr/bin/Packa‌​geApplication" (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.app
  • Jameson
    Jameson over 9 years
    This is the correct answer. The build setting answer forces use of a deprecated API.
  • JimClarke
    JimClarke almost 9 years
    I just installed Xcode 6.4, and SURPRISE!, SURPRISE!, this issue is STILL NOT FIXED. I had to reapply the diff from a above.
  • skitheo
    skitheo almost 9 years
    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.
  • jimpic
    jimpic almost 9 years
    This is ridiculous, Apple common. Start supporting continuous integration NOW.
  • kevinl
    kevinl almost 9 years
    thanks Vladimir, I was getting really confused on this with how it conflicts with Xcode 7 submissions.
  • Hlung
    Hlung almost 9 years
    how exactly do you replace xcrun? I can't see any settings for that in Jenkins Xcode plugin :(
  • bmauter
    bmauter over 8 years
    Thank you @Alistra and @coffeebreaks! I now have that xcode_fix script in my personal bin directory.
  • Gian Franco Zabarino
    Gian Franco Zabarino over 8 years
    @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.
  • Gustavo Barbosa
    Gustavo Barbosa about 8 years
    Your app will be rejected according to Apple: developer.apple.com/library/mac/technotes/tn2206/_index.html‌​#//…
  • Nick N
    Nick N over 7 years
    FWIW - I just used this for XCode 8.2.1 and Bamboo XCode plugin integration. It worked great.