Fastlane Configuration in iOS
According to the previous article Fastlane Magic in iOS, you should have a vision of Fastlane in this article, we didn't spend time explaining Fastlane.
Fastlane Init Issue
first things first, we’ll solve the issue that may happen when we init Fastlane, $ bundle update.
if you have this issue, stop the Terminal current process ( using control + C ).
terminal should be in your project folder then run
sudo bundle update
then delete Fastlane
Folder + Gemfile
+ Gemfile.lock
. then run
fastlane init
Appfile Configuration
The Appfile
store’s useful information is used across all fastlane tools like your Apple ID or the application Bundle Identifier, to deploy your lanes faster and tailored to your project needs.
The Appfile
has to be inside your ./fastlane
directory
if you’re running manual configuration Appfile
will
# app_identifier(“[[APP_IDENTIFIER]]”) # The bundle identifier of your app
# apple_id(“[[APPLE_ID]]”) # Your Apple Developer Portal username# For more information about the Appfile, see:
# https://docs.fastlane.tools/advanced/#appfile
Appfile For one Bundle Identifier
if you have one scheme and one bundle identifier this can be your Appfile
Config
app_identifier("YOUR_APP_BUNDLE") # The bundle identifier of your app
apple_id("YOUR_DEVELOPER_ACCOUNT") # Your Apple Developer Portal username
itc_team_id("YOUR_ITUNES_CONNECT_TEAM_ID") # App Store Connect Team ID
team_id("YOUR_DEVELOPER_TEAM_ID") # Developer Portal Team ID
to get itc_team_id
open https://appstoreconnect.apple.com/WebObjects/iTunesConnect.woa/ra/user/detail
then search for contentProviderId
.
Appfile for Multi Bundle Identifier
if you have a multi bundle identifier and multi scheme your Appfile
Config will be a bit different in this section, we will focus on Multi Bundle. we can have a specific config for each platform or each lane.
Example: I have a project with multi bundle identifiers and multi platform, this can be my Appfile
for_platform :ios do
for_lane :build_Dev do
app_identifier("YOUR_APP_BUNDLE")
apple_id("YOUR_DEVELOPER_ACCOUNT")
team_id("YOUR_DEVELOPER_TEAM_ID")
itc_team_id("YOUR_ITUNES_CONNECT_TEAM_ID")
endend
with this configuration, we can have multiple lanes and special configurations for each lane.
Fastfile Configuration
The Fastfile
stores the automation configuration that can be run with fastlane.
before_all
before_all
will get executed before running the requested lane.
before_all do |lane|
cocoapods # Runs pod install for the project
end
after_all
after_all
will get executed after running the requested lane.
after_all do |lane|
slack(
message: "Successfully submitted new App Update"
) # Send a success/error message to your Slack group
end
error
error
will get executed when an error occurs in any of the blocks.
error do |lane, exception|
slack(
message: "Something went wrong with the deployment.",
success: false,
payload: { "Error Info" => exception.error_info.to_s }
)
end
import another Fastfile
you can import another Fastfile with two methods:
- import from local path
- import from git
import from local Path
import "../OtherFastfile"
import from git
import_from_git(
url: 'https://github.com/fastlane/fastlane'
) Orimport_from_git(
url: 'git@github.com:MyAwesomeRepo/MyAwesomeFastlaneStandardSetup.git',
path: 'fastlane/Fastfile'
)
Fastlane Actions
Fastlane has many actions that we can't introduce of them in this article you can find your specific action on the Fastlane Actions Page.
Fastlane Exit Status
Exit Status 70
Exit Status 70, in Build_app
:
Error Domain=IDEProfileLocatorErrorDomain Code=1 “No profiles for ‘YOUR_BUNDLE’ were found” UserInfo={IDEDistributionIssueSeverity=3, NSLocalizedDescription=No profiles for ‘YOUR_BUNDLE’ were found, NSLocalizedRecoverySuggestion=Xcode couldn’t find any iOS App Store provisioning profiles matching ‘YOUR_BUNDLE’. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.}
if you get this Exit Status, Open Xcode -> Preferences -> Accounts
and click your developer account that conform to this Bundle, then check your login status.
Exit Status 65
if you get Exit status 65, Open Xcode -> Preferences -> Accounts
and click your developer account and click Download Manual Profiles
.
Upload To TestFlight Or App Store
when you run upload_to_testflight
fastlane will ask for your Apple ID and Apple ID password, if your account two-step authentication is enabled, it asks you to generate an App-Specific Password, open
appleid.apple.com -> Sign-In and Security -> App-Specific Passwords
Click on Generate an App-Specific Password and name it, then copy your App-Specific Password and paste it into Terminal.