Deploying an iOS App using fastlane

Deploying an iOS App using fastlane

Step 1: Set up an App ID (or bundle ID) at developer.apple.com

Click on "Identifiers" on the main Apple Developer page:

Apple Developer Identifiers

Click on the "+" icon to add a new App ID:

New App ID

Choose "App IDs" and click "Continue":

New App IDs

Choose "App" (not "App Clip"):

Create new App

On the "Register an App ID" screen, do the following:

  1. Enable these permissions:
  • Apple Pay Payment Processing
  • Associated Domains
  • Push Notifications
  1. Enter a description (such as "Matter Mobile App")
  2. Enter a Bundled ID in format "app.[brand].[type-of-app]", such as "app.matter.mobile"

Register an App ID

Click "Continue" and then click "Register".

Step 2: Set up a new app on App Store Connect

Visit App Store Connect and click the "+" icon. Choose "New App" in the popup, and fill out the New App modal like so:

New App Modal

You will then be redirected to the App Information page, which looks like this:

App Information

This is all you need to do for now.

Step 3: Set up a new GitHub repo for your app's certificates & profiles

Create a new PRIVATE repository for your app's certificates & profiles, such as this:

New GitHub Repo

Step 4: Set up fastlane

This is a more a succinct summary of this post here, which is excellent:

Infinite Red: Fastlane — Simple React Native iOS Releases

First off, install fastlane if you don't already have it installed via the steps here:

https://docs.fastlane.tools/getting-started/ios/setup/

Installing via Homebrew is typically easiest and what I did.

cd into your app's root project folder (if you're using a monorepo, do this in the app directory (such as /apps/kiosk), not the root directory) and run this:

fastlane match init

Choose the "git" storage mode and copy/paste the URL of the GitHub repo you created in the previous step, such as:

https://github.com/jcharrington4/mobile-certs.git

fastlane match init

If you're prompted to update fastlane, you can do so via the command they provide (`fastlane update_fastlane) in the current working directory.

Choose a passphrase (such as "mattermobileapp") make sure to make note of it. This is really important.

Follow the prompts, providing your credentials when prompted.

When this completes, run each of these to set up App Store deployments and local development.

However, before you can run fastlane match development, you must register a device in your Apple Developer account, which looks like this:

register a device

fastlane match appstore
fastlane match development

Once this has been completed, cd into the ios directory and run:

fastlane init

Per the image below, start with option 2 "Automate beta distribution to TestFlight"

fastlane init

Once this has been completed, you can adjust the setup and credentials to make for a smoother flow.

First off, create two env vars files:

.env with your Apple Developer username (APPLE_ID for fastlane) and n application-specific password:

APPLE_ID=jc.harrington1@gmail.com
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD=aaaa-bbbb-cccc-dddd

Doing this will save you the trouble of having to log in each time you produce a new build. You can create an application-specific password here:

https://account.apple.com

Then create an .env.default file that holds the Appfile credentials like this:

APP_ID=[bundle ID of the app, such as app.matter.mobile]
ITC_TEAM_ID=[itc_team_id added to Appfile during fastlane setup]
TEAM_ID=[team_id added to Appfile during fastlane setup]
APP_STORE_APPLE_ID=["Apple ID" from the App Information page on App Store Connect]

Then update your Fastfile to look like this:

default_platform(:ios)

platform :ios do
  desc "Push a new beta build to TestFlight"
  lane :beta do
    increment_build_number(xcodeproj: "mobile.xcodeproj")
    sync_code_signing(type: "appstore")
    build_app(workspace: "mobile.xcworkspace", scheme: "mobile")
    upload_to_testflight(skip_waiting_for_build_processing: true, apple_id: ENV['APP_STORE_APPLE_ID'])
  end
end

Changes that were made:

  1. Add sync_code_signing(type: "appstore")
  2. Add the skip_waiting_for_build_processing: true, apple_id: ENV['APP_STORE_APPLE_ID'] arguments to the upload_to_testflight command

Lastly, move your Matchfile to the ios/fastlane directory from your root project folder (it will work in either place) and set the default type to "appstore", like this:

git_url("https://github.com/jcharrington4/matter-mobile-certs.git")

storage_mode("git")

type("appstore")

Step 5: Prepare Xcode for building

On the General tab, set your Minimum Deployments, Identify, and Deployment Info similar to this:

General

Most notably, update your Bundle ID to reflect the one you created above.

Then move over to "Signing & Capabilities" and uncheck the box for "Automatically manage signing" so it should look like this (when you're running locally for development):

Xcode Signing & Capabilities

"Release" should be set to match AppStore like so:

Release

"Debug" should be set to match Development like so:

Debug

Next, you'll need to add app icons (otherwise the build will fail).

Visit App Icon Generator to generate the full icon set from a 1024 x 1024 pixel PNG imgae.

App Icon Generator

This will generate an App Icon set that looks like this:

App Icon Set

Drag and drop these icons into Xcode in the appropriate spots based on dimenions:

AppIcon Empty

AppIcon Populated

Step 6: Rename display name on the home screen

For Android, navigate to strings and change the app_name like this:

Android

For Android, navigate to Info.plist and change the CFBundleDisplayName like this:

iOS

Note: if you want to update the splash screen, you need to do that separately.

Source: Change App Name in React Native for Android and iOS

Step 7: Deploy the app to TestFlight

Run

fastlane beta

in your ios directory.