Sub topic 3
Building an iOS archive and IPA
This chapter assumes you have a Mac with Xcode, an Apple Developer account, and the iOS signing setup from the previous section. You should know the flutter command-line tool and the difference between debug and release builds.
Building the IPA
An IPA is the iOS package file that you upload to App Store Connect. From the project root, run:
flutter build ipa --releaseFlutter compiles the Dart code, creates an Xcode archive, and writes the IPA to build/ios/ipa/. If the build fails with a signing error, open ios/Runner.xcworkspace in Xcode and check the Signing & Capabilities tab for the Runner target.
Testing on real devices
Test the release build before you submit it. Connect an iPhone, list its ID with flutter devices, and run:
flutter run --release -d <device-id>Release builds do not support hot reload or Dart debugging, so test the app's behavior rather than relying on debug tools. For a fuller check, install the build through TestFlight, described below.
Publishing to Google Play testing tracks
Build the Android App Bundle:
flutter build appbundle --releaseUpload build/app/outputs/bundle/release/app-release.aab in the Play Console. Start on the Internal testing track, then promote the release to closed or open testing, and finally to production.
Publishing through TestFlight and the App Store
Upload the IPA with Transporter or the Xcode Organizer. App Store Connect then processes the build, which can take from a few minutes to an hour. Add the build to a TestFlight internal testing group. When you are ready for the public, attach the build to an App Store version and submit it for review.
Automating the release pipeline
A continuous integration (CI) service is a server that runs your build steps automatically, often on each version tag. Store the keystore, the key.properties file, and Apple credentials as encrypted secrets in the CI service. Never commit them to the repository. A typical pipeline checks out the code, runs the build commands above, signs the output, and uploads it to each store.
Exercise
Why must the build number increase with each upload?
Show answer
Both stores reject an upload whose build number matches or is lower than an earlier upload of the same app version. Each new build needs a higher number, such as 1.2.0+8 after 1.2.0+7.