Deploy your Flutter iOS app on the Apple Store

Signing an iOS app is an important process that guarantees the app originates from the developer and has not been modified since publication. Signing uses a digital certificate to associate the app with its developer and to verify the integrity of the app.

Without a valid signature, the application cannot be installed or run on an iOS device.

Prerequisites

It's important to note that if you don't have a paid account for the Apple Developer Program, you will not be able to distribute your apps on the App Store, and you will not be able to take advantage of advanced development features (such as iOS app signing).

Sign your app automatically

Once you have a paid account for the Apple Developer Program, and logged in to Xcode with your Apple ID, you can sign your app automatically.

signing app automatically flutter template

Create a certificate manually

ℹ️ XCode provides a feature to automatically create a certificate. For simple projects, this feature is sufficient.

The certificate is a file that allows you to sign your application and thus to deploy it on an iOS device. It is created as part of Apple's developer program and must be renewed regularly to continue to be used.

To create a certificate you have to follow this official guide Creating Certificates for iOS Devices | Apple Developer Documentation.

  1. In Certificates, Identifiers & Profiles, click Certificates in the sidebar.
  2. On the top left, click the add button (+).
  3. Under Software, select Developer ID, then click Continue.

Developer ID Application: A certificate used to sign a Mac app.
Developer ID Installer: A certificate used to sign a Mac Installer Package, containing your signed app.

  1. Follow the instructions to create a certificate signing request.
  2. Click Choose File.
  3. In the dialog that appears, select the certificate request file (a file with a .certSigningRequest file extension), then click Choose.
  4. Click Continue.
  5. Click Download.

The certificate file (a file with a .cer file extension) appears in your Downloads folder.
To install the certificate in your keychain, double-click the downloaded certificate file. The certificate appears in the My Certificates category in Keychain Access.

Create an app identifier

Un identifiant d’application permet d'identifier de manière unique l'application et son développeur.

Voici comment créer un identifiant d’application:

  1. Go on that link Certificates, Identifiers & Profiles - Apple Developer.
  2. Then click on the blue "+" button to add a new unique identifier.

select apple identifier xcode

  1. Then select "App IDs", and click on "Continue".

Capture d’écran 2023-03-14 à 09.29.15.png

  1. Select the corresponding app ID type, i.e. "App", then click on "Continue".

Capture d’écran 2023-03-14 à 09.30.13.png

  1. On the next page, you'll need to fill in several fields

-Description: A short description of the application identifier.
-Bundle ID: The application's unique identifier, usually io.apparence. (e.g. io.apparence.monsuividiet). Avoid capitalization, spaces and underscores/dashes.
-Capabilities: Application-related capabilities can be updated later, so you can leave them unchecked at first.

Capture d’écran 2023-03-14 à 09.33.27.png

  1. Then click on "Continue" and finally on "Register" to save the app ID.

The app ID is now created! Now we can move on to creating a provisioning profile.


Create a provisionning profile manually

ℹ️ XCode provides a feature to automatically create a provisioning profile. For simple projects, this feature is sufficient

A provisioning profile on iOS is a file that allows you to deploy an application on an iOS device for testing or for limited distribution to specific users. The provisioning profile is associated with a digital certificate and a unique application ID (which we created earlier), and guarantees that the application is distributed by a trusted developer.

It is created as part of Apple's developer program and must be renewed regularly to continue to be used.

  1. Go to the following link Certificates, Identifiers & Profiles - Apple Developer
  2. Then click on the blue "+" button to create a new profile.

Capture d’écran 2023-03-14 à 09.44.35.png

  1. We'll now need to choose the type of our provisioning profile (we'll only develop the types for iOS).

iOS App Development: If you want to deploy an application for development on test devices (i.e. on a real phone for development directly connected to Xcode, for example).
Ad Hoc: To deploy an application to a limited number of devices (mainly used for beta applications such as Firebase App Distribution or TestFlight).
App Store: Used to deploy an application to the AppStore and thus to an unlimited number of devices.

  1. In this tutorial, we'll select "Ad Hoc" and then click on "Continue" in the top right-hand corner.

Capture d’écran 2023-03-14 à 09.55.07.png

  1. In the next step, you'll need to select the app ID we created earlier from the list. Then click on "Continue".

Capture d’écran 2023-03-14 à 09.56.46.png

  1. The next step is to select the certificate that will be associated with the provisioning profile. Here we'll choose the "SPLURB (Distribution)" certificate with the farthest expiry date. Then click on "Continue".

Capture d’écran 2023-03-14 à 09.59.52.png

  1. In this new screen, you are invited to select the devices that will be eligible to install and launch the application (this step is not necessary for an AppStore provisioning profile). Then click on "Continue".

Capture d’écran 2023-03-14 à 10.05.33.png

  1. Then give the provisioning profile a name. In general, we use the following nomenclature: " - "

Capture d’écran 2023-03-14 à 10.09.13.png

  1. Now click on “Generate”.

The provisioning profile is now generated. Note that you don't need to download it locally to your computer, as we'll be able to do this directly from Xcode in the next step.

Download the provisioning profile

Now that the provisioning profile is created, we'll need to download it to our computer.

Important: This step is important because the automatic download still doesn't work with Flutter when building iOS…

It's also important to perform this operation on the machine that will sign the application, i.e. at Apparence, the iMac that acts as the CI (it can be accessed via screen sharing or physical).

  1. Open Xcode, then click on the context menu, then "Settings".

Capture d’écran 2023-03-14 à 10.17.46.png

  1. Now click on download profiles then wait a little

The provisioning profile has now been successfully downloaded and is ready for use.

Sign your iOS app

It's now possible to sign your application, and in this tutorial we'll look at how to do it from within Xcode and then via Flutter on the command line.


Build your Flutter app (with CLI command)

Run this command

flutter build ipa --release \
--dart-define=BACKEND_URL=https://us-central1-apparencekit-pro.cloudfunctions.net/app \
--dart-define=ENV=dev

If you have setup flavors, you can run this command

flutter build ipa --release --flavor <flavor_name> \
--dart-define=BACKEND_URL=https://us-central1-apparencekit-pro.cloudfunctions.net/app \
--dart-define=ENV=dev

Don't forget to add all your environment variables.

That's one of the reason I encourage you to use a CI to build your app.

You will find the result ipa in the build/ios/ipa/[APP_NAME].ipa


Publish your app on the App Store

  1. Connect on Apple Connect App Store Connect (apple.com).
  2. Click on the “+” blue button, then “New app”.

Capture d’écran 2023-03-14 à 11.23.38.png

  1. Select the platform (iOS, tvOS, etc.) for which you want to publish your application.
  2. Enter basic application information, including name, description, screenshots and icon.

Capture d’écran 2023-03-14 à 11.24.35.png

  1. Download the "Transporter" application on the Mac AppStore.
  2. Signin with your Apple ID.
  3. Click on "Add an app" or drag and drop the IPA file into the window below.
  4. Click on "Deliver" and wait for the upload to finish.

Note: Apple process your app before you can submit it to the App Store. This can sometimes takes hours or just minutes. Once the process is done, you can submit your app to the App Store.

Pushing an update

You must increment the version number of your app in the pubspec.yaml file. Then you can generate a new AppBundle file and upload it to the Google Play Store.

like this

version: 1.0.0+1
version: 1.0.0+2

Note: Flutter encourage you to use the Semantic Versioning to manage your app version.

Then you can run the build command again