Integrate Fastlane to iOS project: Lesson 2
In lesson 1, we installed the need tools. After that we are going to integrate Fastlane to our iOS project now.
Initial Fastlane in your iOS Project
Go to iOS project directory, type init cmd to initial the Fastlane
Fastlane init
You will see the following screen when you are initialing Fastlane.
In your project directory, it should have 2 new files, named Gemfile
and Gemfile.lock
and 1 folder named fastlane
.
Gemfile
and Gemfile.lock
are Ruby
related files, it mentions that you have import Fastlane to your project. Most of the time you don’t need to work on that.
fastlane
is a folder, which contain 2 files. Appfile
is used to store the app related information, such as apple ID
, app identifier
. In this tutorial, we won’t use that file since we will set up different environments for different values. Fastfile
is the most frequently edited file. It lets you to write the script to tell Fastlane which app should do which actions.
Create your first lane
lane is a basic unit in Fastlane, it is similar func
in swift. Open your fastfile
and paste the following code.
default_platform(:ios)platform :ios do
lane :hello_world do
puts("hello world") // print this message
end
end
type the following cmd in Terminal.
bundle exec fastlane ios hello_world
and you will get the following output.
bundle exec
is used to run the specify Fastlane version in your gemfile
. If the cmd is not typed, it will run the current version in your Mac.
fastlane
is the cmd to execute Fastlane.
ios
is used to indicated the platform is iOS.
hello_world
is the lane you defined in fastfile
.
What’s next?
Next lesson, we will introduces Fastlane action and start to get the certificates and provisioning profile from your Apple Developer Account by using Fastlane in order to build the app.