7

UPDATE: The correct answer is probably this one: Xcode 6.1 error while building IPA

Using Jenkins to build iOS projects from repositories since a few years. Suddenly today a new error occurs, stopping builds.

I think I based most of this setup on this tutorial way back:

http://www.raywenderlich.com/22816/beginning-automated-testing-with-xcode-part-22

This step causes the error:

# 4
echo "*** Post build step 4"
/usr/bin/xcrun -sdk iphoneos PackageApplication \
-o "${IPA_DIR}/${PROJECT}.ipa" \
-verbose "${APP}" \
-sign "${SIGNING_IDENTITY}" \
--embed "${PROVISIONING_PROFILE}"

It's a bit tricky to look at the logs where the error occurs, but here it is:

### Codesigning '/Users/Shared/Jenkins/Home/jobs/myapp/workspace/myapp_adhoc_7.mobileprovision' with 'iPhone Distribution: mycompany Inc.'
+ /usr/bin/codesign --force --preserve-metadata=identifier,entitlements,resource-rules --sign iPhone Distribution: mycompany Inc. --resource-rules=/var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app/ResourceRules.plist --entitlements /var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/entitlements_plistYdluSmqT /var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app
Program /usr/bin/codesign returned 1 : [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!
/var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app/ResourceRules.plist: cannot read resources
]
error: /usr/bin/codesign --force --preserve-metadata=identifier,entitlements,resource-rules --sign iPhone Distribution: mycompany Inc. --resource-rules=/var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app/ResourceRules.plist --entitlements /var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/entitlements_plistYdluSmqT /var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.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!
/var/folders/y1/4hrpc2851b7dxn9bhlkhbrnr00007q/T/ipIxOjxE2z/Payload/myapp.app/ResourceRules.plist: cannot read resources

I'll try to fix this myself and later add the solution here, but in case anyone is faster than me please go ahead.

  • I have not specified --resource-rules in any settings. I guess xcrun uses this setting on its own, even though it is deprecated.
Community
  • 1
  • 1
Jonny
  • 15,955
  • 18
  • 111
  • 232

2 Answers2

11

Instead of using xcrun, you can use xcodebuild to create an archive and then run xcodebuild again to create the IPA file.

# Create an archive
xcodebuild -alltargets -configuration "${CONFIGURATION}" -scheme "${SCHEME}" -archivePath "${APP_PATH}/${PROJECT}.xcarchive" archive

# Create the IPA file from the archive
xcodebuild -exportProvisioningProfile "${PROVISIONING_PROFILE_NAME}" -exportArchive -exportFormat IPA -archivePath "${APP_PATH}/${PROJECT}.xcarchive" -exportPath "${IPA_DIR}/${PROJECT}.ipa" CODE_SIGN_IDENTITY="${SIGNING_IDENTITY}"

Note that ${PROVISIONING_PROFILE_NAME} should contain the name of the provisional profile, and not the path to the file itself.

Gil Osher
  • 176
  • 1
  • 5
8

Found the answer.

The problem that occurred now was the "xcrun PackageApplication" something something line. I had to remove the "-sign some profile" parameter, then things started working again.

That said I don't know why signing was necessary before, and why it isn't now so can't tell if this is going to cause some problem later.

Jonny
  • 15,955
  • 18
  • 111
  • 232
  • 3
    Simply remove signing isn't a good idea if you distribute your app. Your xcrun PackageApplication fails due to the deprecated parameter --resource-rules used by xcrun. Apple made that obsolete a while ago but didn't update xcrun to simply omit that. That's the reason why from here on codesigning simply fails if the ResourceRules.plist isn't there – Evils Nov 11 '14 at 21:05
  • So what do you suggest, do you have a better answer? – Jonny Nov 14 '14 at 01:13
  • This: http://stackoverflow.com/a/26499526/129202 has a lot of upvotes, it might be correct. – Jonny Nov 14 '14 at 01:23
  • Indeed http://stackoverflow.com/questions/26497863/xcode-6-1-error-while-building-ipa-using-testflight-app/26499526#26499526 is the "correct" answer, at least it worked for me, and a ton of other people... – Jonny Nov 14 '14 at 01:34
  • [stackoverflow.com/questions/26497863/...](http://stackoverflow.com/questions/26497863/xcode-6-1-error-while-building-ipa-using-testflight-app/26499526#26499526) worked for me as well. Thanks! – JavaSplice Jan 08 '15 at 16:28