Full Stack iOS Continuous Delivery with xcodebuild and ExportOptions Plist

Originally Posted on XCTEQ, XCBlog

The process of uploading iOS binary files to the App Store is time-consuming and (let’s face it) boring. And Apple hasn’t provided better options for this process. As of now, we’ve used various tools to upload .ipa files to App Store Connect. The most common method for solo iOS developers is to upload directly from Xcode or use the Application Loader tool, which is integrated in Xcode.

For established companies, engineers configure Continuous Integration servers to upload binary files to App Store Connect using command line tools like altool, iTMSTransporter or Fastlane deliver.

I’ve covered these options in detail in a previous post (here). Fortunately, with Xcode 10, we can upload binary files to App Store Connect just using xcodebuild and an exportOptionsPlist file. In this short post, we’ll see how we can achieve this.

Archive App

xcodebuild has an -exportArchive option to create an IPA that works more like Xcode Organizer. This involves two steps:

  1. Build an archive with xcodebuild archive
  2. Create the .ipa file with xcodebuild -exportArchive

We now build the archive like this:

We now export the .ipa like this:

These two commands create the build/MY_APP.xcarchive and build/MY_APP.ipa files.

Note that the above command requires an -exportOptionsPlist argument that points to a Plist file with export options. For a complete list of what you can put in that plist, run xcodebuild -help The minimal contents of the file look 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>method</key>
    <string>app-store</string>
    <key>teamID</key>
    <string>YOUR_TEN_CHARACTER_TEAM_ID</string>
</dict>
</plist>

Once we run this command successfully, we’ll have an .ipa file created using the specified provisioning profile. In the end, we’ll have our MY_APP.ipa binary ready to upload to iTunes Connect.

At this point, we’d normally need to use the tools like altool, iTMSTransporter or Fastlane deliver to upload the binary to the App Store. However, we don’t need these tools with Xcode 10. We can specify the upload to App Store Connect directly from the Plist file.

Modify ExportOptions Plist for Direct Upload

In Xcode 10, we have a new option in the ExportOptions.Plist file that will enable us to upload binary files to App Store Connect without using tools like altool, iTMSTransporter or Fastlane deliver.

The xcodebuild -exportArchive command will perform an upload if the provided ExportOptions.plist contains a key named “destination” with value “upload”. We need to have an Apple ID account with the necessary App Store Connect role, and provider membership must be added in Xcode’s account preferences panel.

There are various destitution methods supported to upload the binary to the App Store. The commonly used distribution methods are appstore, developer-id, and validation .

In order to upload the app directly using the xcodebuild tool we have to modify theExportOptions.Plist file to look 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>method</key>
    <string>app-store</string>
    <key>teamID</key>
    <string>YOUR_TEN_CHARACTER_TEAM_ID</string>
    <key>destination</key>
    <string>upload</string>
</dict>
</plist>

With this approach, we can upload the apps to the App Store without using any third-party tools.

Conclusion

Finally, full stack iOS continuous delivery can be achieved using xcodebuild itself. It’s time to drop some of these CI/CD tools land utilize the full power of xcodebuild to upload binaries to the App Store Connect. I hope you’ll adopt these new features in your iOS CI/CD workflow very soon.

Discuss this post on Hacker News.

====================================

Like this post from XCBlog By XCTEQ ? You may also like some of our open source projects on Github or Follow us on Twitter and LinkedIn

Avatar photo

Fritz

Our team has been at the forefront of Artificial Intelligence and Machine Learning research for more than 15 years and we're using our collective intelligence to help others learn, understand and grow using these new technologies in ethical and sustainable ways.

Comments 0 Responses

Leave a Reply

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