Search code examples
iosxcodexcodebuild

xcodebuild produces different archive to Xcode 7.0.1


I am using xcodebuild to generate an archive from a workspace. I use the following command:

xcodebuild -workspace MyProject.xcworkspace -scheme "MyProject" 
           -destination generic/platform=iOS archive 
           -archivePath "../PathToArchive/MyProject.xcarchive

(I've spaced it out over multiple lines for readability)

This command generates a MyProject.xcarchive. However it generates a generic "Xcode Archive" rather than an "iOS App Archive." This cannot be submitted to the App Store.

If I archive the exact same workspace and scheme using Xcode.app version 7.0.1 (7A1001) instead of xcodebuild then I get an "iOS App Archive" which can be submitted to the App Store.

Inspecting the contents of these two xcarchives shows the main difference is the bundled Info.plist file. The one generated by Xcode.app contains an additional ApplicationProperties dict with versioning and signing details. The one generated by xcodebuild lacks these details in its Info.plist.

Copying the Xcode.app generated Info.plist into the xcarchive generated by xcodebuild "fixes" the archive, and it can be submitted to the App Store. This is not a solution however, as it means I cannot build on the command line.

Note that doing xcodebuild -version prints:

Xcode 7.0.1
Build version 7A1001

Edit: sometimes xcodebuild appears to generate a correct iOS App Archive instead of a Generic Archive. I'm not exactly sure why this happens. It's not consistent.


Solution

  • After a lot of frustration I have discovered the cause of xcodebuild producing incorrect xcarchive packages.

    I had to disable the "Parallelize Build" option for the scheme I was building.

    Parallelize Build Setting

    After un-ticking this option, the builds take a lot longer, but xcodebuild is consistently producing an "iOS App Archive" rather than a "Generic Archive." With "Parallelize Build" enabled xcodebuild would generate a "Generic Archive" 90% of the time, occasionally generating a correct archive.

    Because I wanted my build times within Xcode to remain unaffected, I left the "Parallelize Build" option enabled for my schemes. I duplicated the schemes to be built with xcodebuild and un-ticked the option only for the deployment schemes.