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.
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.
xcodebuild has an -exportArchive option to create an IPA that works more like Xcode Organizer. This involves two steps:
- Build an archive with xcodebuild archive
- 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
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.
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.