Using -exportArchive instead of Package Application to export an IPA

After upgrading to Xcode 7, my command line build script to build and package ipas started to fail because of this error:

usage of --preserve-metadata with option "resource-rules" (deprecated in Mac OS X >= 10.10)!

--resource-rules has been deprecated in Mac OS X >= 10.10!

I did some research and learned that my method of exporting the ipa by using xcrun and the PackageApplication script uses –resource-rules and there is no way to get around it without actually updating the script itself. Since that seemed like a terrible way to resolve the issue, I did a little more research and found the proper way of exporting an ipa without using PackageApplication. Here is a before and after look at my build script.

Before: xcrun with PackageApplication

# Build the application
xcodebuild \
-scheme "${SCHEME_NAME}" \
-sdk "${TARGET_SDK}" \
-configuration Release build

# Package the application
/usr/bin/xcrun \
-sdk "${TARGET_SDK}" \
PackageApplication \
-v "${PROJECT_BUILDDIR}/${SCHEME_NAME}.app" \
-o "${BUILD_OUTPUT_DIR}/${APP_NAME}.ipa" \
--sign "${DEVELOPER_NAME}" \
--embed "${PROVISIONING_PROFILE}"

After: xcodebuild with -exportArchive

# Archive the application
xcodebuild \
-scheme "${SCHEME_NAME}" \
-sdk "${TARGET_SDK}" \
-archivePath "${PROJECT_BUILDDIR}/${SCHEME_NAME}.xcarchive" \
-configuration Release \
PROVISIONING_PROFILE="${PROVISIONING_PROFILE}" \
archive 

# Export the archive to an ipa
xcodebuild \
-exportArchive \
-archivePath "${PROJECT_BUILDDIR}/${SCHEME_NAME}.xcarchive" \
-exportOptionsPlist "${EXPORT_PLIST}" \
-exportPath "${BUILD_OUTPUT_DIR}" 

The -exportArchive method does require a plist file with a few key values. The configuration changes depending on wether it is an enterprise or App Store ipa. This is what the plist files should look like:

Enterprise plist

<?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>method</key>
	<string>enterprise</string>
	<key>teamID</key>
	<string>**********</string>
	<key>compileBitcode</key>
    <false/>
</dict>
</plist>

App Store plist

<?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>method</key>
	<string>app-store</string>
	<key>teamID</key>
	<string>**********</string>
</dict>
</plist>

This method has been working great so far. Let’s hope it survives the next Xcode upgrade!

References

Here are links to articles that helped me with this:

Share this on → Twitter Facebook Google+