What is fastlane? Fastlane is an open source platform aimed at simplifying Android and iOS deployment–automating the process of building and releasing mobile apps.
What is fastlane?
Fastlane is an open source platform aimed at simplifying Android and iOS deployment–automating the process of building and releasing mobile apps.
(Note: If you are looking to add existing certificates to match git repo, Go to step 9.)
With fastlane, you can:
Automate screenshots — Automatically generate localized screenshots for the app store.
Distribute beta deployments — Easily distribute beta builds for testers.
Publish app store deployments — Publish a new release to the app store in seconds.
Simplify code signing — Reliably and consistently code sign your app, no more headaches.
What is fastlane match?
Fastlane match offers a new approach to iOS code signing: Share one code-signing identity across your development team to simplify your code signing setup and prevent code signing issues.
When you use match, you can create all required certificates & provisioning profiles and store them in a separate git repository. Every team member with access to the repo can use those credentials for code signing. Match also automatically repairs broken and expired credentials. It’s the easiest way to share signing credentials across teams.
Before setting up fastlane match, Let’s start by installing fastlane on the local machine.
sudo gem install fastlane
Step 1: Create a git repo.
Create a new, private git repo (e.g in a specific project in bitbucket.org/xxx), and you can name it “certificates”.
Note: Make sure the repository is set to private.
Step 2: Create an Apple developer account.
Create a new, shared Apple developer account, (like email@example.com) that will be shared across your team from now on.
If you already have one, ignore this step. You can also add the username and password fields for the account within the match file.
Step 3: Set up ssh key.
Setting up a ssh key for your git account means you can clone the repository, which will be used by fastlane match file. This is important since match requires username and password to access git repo. Without authentication, the build fails.
Using ssh, You can authenticate for the repository where certificates and provisioning profiles will be stored.
Step 4: Initiate fastlane. Initiate fastlane for your project folder (containing .xcworkspace or .xcodeproj).
fastlane init project1$: fastlane init [17:13:06]: Detected iOS/Mac project in current directory... [17:13:06]: This setup will help you get up and running in no time. [17:13:06]: fastlane will check what tools you're already using and set up [17:13:06]: the tool automatically for you. Have fun! [17:13:06]: Created new folder './fastlane'. [17:13:06]: $ xcodebuild -list -workspace ./project1.xcworkspace 2017-06-20 17:13:07.122 xcodebuild[65932:6932431] [MT] PluginLoading: Required plug-in compatibility UUID DFFB3951-EB0A-4C09-9DAC-5F2D28CC839C for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/SwiftLintXcode.xcplugin' not present in DVTPlugInCompatibilityUUIDs [17:13:08]: $ xcodebuild -showBuildSettings -workspace ./project1.xcworkspace -scheme project1 2017-06-20 17:13:08.331 xcodebuild[65937:6932494] [MT] PluginLoading: Required plug-in compatibility UUID DFFB3951-EB0A-4C09-9DAC-5F2D28CC839C for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/SwiftLintXcode.xcplugin' not present in DVTPlugInCompatibilityUUIDs [17:13:09]: Your Apple ID (e.g. firstname.lastname@example.org): email@example.com Verifying that app is available on the Apple Developer Portal and iTunes Connect... [17:15:49]: Starting login with user 'firstname.lastname@example.org'
A folder with name fastlane is created inside the project folder. It contains three files initially–out of which two are important.
Appfile — The Appfile stores useful information that is used across all fastlane tools like your Apple ID or the application Bundle Identifier, to deploy your lanes faster and tailored on your project needs
Fastfile — Defines the “lanes” that drive the behavior of fastlane.
Step 5: Update fastfile
Update the fastfile with required lanes such as beta, appstore, etc. If you want to know about these commands. Click here.
In this example, we are using beta for uploading the build to crashlytics.
There are few additional things that are shown in this example. (e.g: Bumping the build version, configuring slack etc.)
Step 6: Set up match.
— To setup match
fastlane match init
You need to provide the url for the git private repo. (Recommended to use ssh instead of https, Follow step 1 and step 3)
This will create a matchfile in the current directory (or in your ./fastlane/folder).
By default, it contains git url, App Identifier, git username.
Update the file with following commands.
Fastlane will automatically take the username, password for git repo and authenticate.
MATCH_PASSWORD is the password for the p.12 files that will be stored in the repo.
Step 7: Generating certificates
Run the following command in the terminal:
fastlane match appstore
You can also use development, ad-hoc, enterprise depending on your purpose.
This will create a new certificate and provisioning profile (if required) for the type selected (development, ad-hoc, enterprise, appstore), and store them in your git repo. If you previously ran match, it will automatically install the existing profiles from the git repo.
The provisioning profiles are installed in ~/Library/MobileDevice/Provisioning Profiles while the certificates and private keys are installed in your local keychain.
Note: To get a more detailed output of what match is doing, use:
fastlane match --verbose
Step 8: Upload build to crashlytics (optional).
Try uploading the build to fabric from local machine to make sure everything is working as expected. Make sure you have the api_key and build_secret for the application in fabric to upload. Since we have already configured beta lane in fastfile to upload build to crashlytics.
Run the following command from the project folder:
Step 9: Manually add existing certificates to the git repository (optional).
Warning: Manually editing your match repo can introduce unexpected behaviour and is not recommended. Proceed with caution.
Note: GitHelper doesn’t work any more. Fastlane has recently updated the process.
Run the following commands in your terminal:
$ bundle console
Then, require match and set the appropriate parameters:
Now create an instance of Storage and Encryption. The download method on Storage will clone the repo and the decrypt_files method on Encryption will decrypt the repo for you. Assign the return values to storage and encrypt, which we’ll need later when we re-encrypt: