Local Unity builds for Google PlayStore and Apple AppStore - Earth Matters build pipeline notes
Disclaimer
Full confession: this blog entry is basically my notes for running the Earth Matters build pipeline. I will keep it up to date as the tools evolve, so I can continue to build and deploy whatever my current project is.
When you use a variety of tools and publish to multiple App Stores, things change over the course of time it takes to complete the project. I built Earth Matters using Unity. I could have used various cloud build options, but since it is just me, I figured why not do it locally, save some money, and not worry about cloud build solutions that break at various points in time. (And they will break)
Another disclaimer, I have used Unity Cloud Build that publishes directly to the Apple App Store and GooglePlay Store. The build was trigged from a GitHub merge, and build status reported to a Slack channel. It's very nice once it is set up, right up until it breaks. And it will break periodically. Then you are at the mercy of say Unity needing to make changes because either Apple of Google changed something. At that point you can't build or deploy for a few hours or days.
Don't get me wrong, it will still break when using local builds, but at least you can usually get back up and running the same day.
Summary
Using a Mac, Unity, and XCode to build locally and upload you game to the app stores. It feels a little weird writing a blog article for myself, but I want to make sure these notes are preserved and kept up to date. There was a fair amount of sweat and tears that went into this. Thankfully no blood (yet). Maybe not tears either, but there were definitely things that were incredibly frustrating to figure out. Hence the need for this article.
Building Steps
Be careful changing the version number. Changing the major or minor version triggers a manual review by Apple, which usually has a business day turnaround time. Through the initial coding phase of the project, only update the build number part of the version string.
- Update and synchronize the following (in Unity):
- Android - Project Settings → Player → Android → Other Settings → Version* and Bundle Version code (Increment the Bunder Version Code by 1)
- iOS - Project Settings → Player → iOS → Other Settings → Identification Version* and Build (Make the "Build" match Android's "Bunder Version Code")
- Version display - MainMenuScene → Canvas → MainMenu → MM Controller (Script) → Game Version
(make this match the version and build number in the following format "v0.1(4)", where 0.1 is the App Store version number, and 4 is the Play Store Bundle Version Code and App Store Build Number) - User browser to log into Apple App and Google Play stores
- Update approvals for any license changes
- Fix any project errors / review warnings (This is more likely in Google Play)
- It just works better to do this step with Apple. It kicks something authentication-wise
- In Unity, switch to Android - File → Build Settings... → Android → Switch Platform
- Enter the password in: Project Settings → Player → Android → Publishing Settings for both Project Keystore and Project Key
- Build: File → Build Settings... → Build (replace the existing .aab file)
- Using logged in browser, play.google.com → internal testing → look for the (sometimes hidden) "Create Release" button on the top right.
(It is dynamic and sometimes only appears after mousing over it)
- Upload new app bundle (the .aab file)
- Add release notes
- Press "Review Release"
- Start rollout to Internal Testing
- Rollout
- In Unity, switch to iOS and build - File → Build Settings... → iOS → Switch Platform; → Build
- Replace existing Xcode project
- Open generated project in Xcode
- Product → Archive (this will fail! Turn on automatic signing, and select the right team)
- Product → Archive a second time. It should work this time, but if not, fix any errors
- Archives → Distribute App
- Select App Store Connect (for TestFlight)
- Upload
- Leave "Upload Your App's Symbols" and "Manage Version and Build Number" checked. Press "Next"
- Distribution certificate should be set (iOS Distribution); Select the right distribution profile
- Review the .ipa content dialog. Press "Upload" (There will likely be errors that can be ignored. Unity vs Apple)
- IF YOU GET: UnityFramework.framework contains disallowed file 'Frameworks', do the following:
- Click on file tab (top left)
- Select "Unity-iPhone"
- Select "UnityFramework"
- Select "Build Settings"
- Search on "swift"
- Set “Always Embed Swift Standard Libraries” to “No”, and rebuild
- Using logged in browser, go to AppStoreConnect → Apps → TestFlight
- Add missing compliance info: click "Manage" link
- Fill out encryption info and save
- Using device: download and review via TestFlight
- Add external testers to the build
Because each Android submission requires a bump of the Bundle Version Code, do Android first! Apple allows you to make corrections and resubmit with the same version number. (Otherwise, if you want to keep the version numbers synchronized across platforms, you'll have to redo your iOS build if Android submission has an issue.)