Bot Issue: exportArchive: exportOptionsPlist error for key ‘iCloudContainerEnvironment’: expected one of {Development, Production}, but no value was provided

I’m working on an iOS project and recently ran into a problem building on an Xcode 9 server using a bot. The bot was building the project without errors until I enabled the iCloud and Notifications entitlements in the target. After doing this I was getting the following error after a successful build and test run:

Assertion: exportArchive: exportOptionsPlist error for key 'iCloudContainerEnvironment': expected one of {Development, Production}, but no value was provided

The raw build log file for the integration showed this error:

2017-09-24 20:49:12.371 xcodebuild[33474:580767] [MT] IDEDistribution: Step failed: <IDEDistributionOptionsStep: 0x7fda3f442950>: Error Domain=IDEFoundationErrorDomain Code=1 "exportOptionsPlist error for key 'iCloudContainerEnvironment': expected one of {Development, Production}, but no value was provided" UserInfo={NSLocalizedDescription=exportOptionsPlist error for key 'iCloudContainerEnvironment': expected one of {Development, Production}, but no value was provided}
error: exportArchive: exportOptionsPlist error for key 'iCloudContainerEnvironment': expected one of {Development, Production}, but no value was provided

Error Domain=IDEFoundationErrorDomain Code=1 "exportOptionsPlist error for key 'iCloudContainerEnvironment': expected one of {Development, Production}, but no value was provided" UserInfo={NSLocalizedDescription=exportOptionsPlist error for key 'iCloudContainerEnvironment': expected one of {Development, Production}, but no value was provided}

** EXPORT FAILED **

So the bot fails to export the app with an error that seems to suggest I should be using a custom ExportOptions plist file that somehow specifies the value of iCloudContainerEnvironment as either Development or Production.

The bot was setup using the default configuration for Archive/Export of “Installable Product and Thinned Variants”:

There is an option in that same drop list for Export called “Use Custom Export Options Plist”. When you select this option you get a little folder icon you can click on to find a valid ExportOptions.plist file on your disk:

You can generate a valid ExportOptions.plist file using the Xcode Archive and Export functionality in the IDE.

To do this, set the build target as Generic iOS Device:

Then choose Product/Archive.

After the Archive build is completed, in the Organizer window that appears, choose Export… to export the app.

Choose Development and click Next.

Here’s where you get to choose what iCloud Environment to use. I chose Development since I’m testing with the continuous build target. For App Thinning, you can select any value – I chose to thin for all compatible variants. I left the rest of these options at the defaults.

Click Next.

In the next screen you select your distribution certificate and profile. The Team should be prefilled with your correct team – if not, check your Xcode project settings. For the app profile, choose the development profile that’s in the drop list choices and click Next to proceed with the export to your disk.

Once the export of the app is done, you’ll have a folder on your hard drive where you chose to export containing the app plus the ExportOptions.plist file you are looking for. It’s time to edit your Xcode bot to use this plist file.

Back in the Configuration page of your bot, click on the little folder icon under the Export option for Use Custom Export Options Plist to locate and select the ExportOptions.plist file you previously exported. That’s all there is to it!

cdisdero

Software Engineer

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax