Full Stack iOS Continuous Delivery with xcodebuild and ExportOptions Plist

Originally Posted on XCTEQ, XCBlog

Shashikant Jagtap
Heartbeat

--

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:

$ xcodebuild -workspace YOUR_WORKSPACE.xcworkspace -scheme YOUR_SCHEME -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MY_APP.xcarchive

We now export the .ipa like this:

$ xcodebuild -exportArchive -archivePath $PWD/build/MY_APP.xcarchive -exportOptionsPlist ExportOptions.plist -exportPath $PWD/build

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:

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:

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

Editor’s Note: Heartbeat is a contributor-driven online publication and community dedicated to providing premier educational resources for data science, machine learning, and deep learning practitioners. We’re committed to supporting and inspiring developers and engineers from all walks of life.

Editorially independent, Heartbeat is sponsored and published by Comet, an MLOps platform that enables data scientists & ML teams to track, compare, explain, & optimize their experiments. We pay our contributors, and we don’t sell ads.

If you’d like to contribute, head on over to our call for contributors. You can also sign up to receive our weekly newsletters (Deep Learning Weekly and the Comet Newsletter), join us on Slack, and follow Comet on Twitter and LinkedIn for resources, events, and much more that will help you build better ML models, faster.

--

--

All the posts published on this channel before I joined Apple. Thanks for being a reader of XCBlog. Web: shashikantjatap.net, xcteq.co.uk