IOS package publishing tool Fastlane junior Raiders

I’ve been doing continuous releases using xcbuild and xctool for packaging, but I often encounter certificates related issues, Provising Profile files that don’t match, and then certificates don’t match, and so on. So they started looking for a new solution, and found a new artifact, fastlane.

Relevant information

Fastlane is a full set of tools to help developers, mainly iOS developers, pack App, upload App to App store, or TestFlight.
Fastlane repo
https://github.com/fastlane/fastlane
official address: Fastlane fast start https:// docs.fastlane.tools/actions/ document
document: action
https://docs.fastlane.tools/
Fastlane support

Install Fastlane

1. make sure the Xcode command line tool has been installed.
`xcode-select –install`
2. refers to the official document. There are three ways of installing and installing any of the official documents

IOS package publishing tool Fastlane junior Raiders
Paste_Image.png

Packaging using Fastlane

1. initialize the project Fastlane init
. Using Fastlane must first initialize the project. Fastlane init
A. uses the command line tool to enter the project directory and execute the Fastlane init command

IOS package publishing tool Fastlane junior Raiders
Paste_Image.png

During initialization, you need to fill in some of the project information, including scheme, name, and your Apple, ID, and so on. At the same time, a folder of Fastlane is generated in the project.

2. check the contents of the Fastlane folder.
says that after initialization, a folder of Fastlane will be generated in the project root, and then open the folder to have a look

IOS package publishing tool Fastlane junior Raiders
Paste_Image.png

There are 4 files in the folder

  1. Appfile contains the basic information about App, including app_identifier, apple_id, team_id, and so on. If you enter the correct appId account number and password at the first step of init, the correct team_id information is generated here.
  2. Fastfile is the most important file that you can write and customize a file of our packaged scripts, and some of our custom features are written here.
  3. README.md there are some help explaining information
  4. Report.xml doesn’t need it

Fastfile

Next, post the contents in Fastfile

IOS package publishing tool Fastlane junior Raiders
Paste_Image.png

The first few lines of
recorded the version information of
. Fastlane starts from platform: IOS do, and the following is the task that Fastlane can perform,
first

Before_all do cocoapods end

This point means that you perform the function first before you execute each lane. It actually runs a Fastlane action, and this action is called cocoapods. 3.1 see Fastlane action
and action
in the usage of before_all mentioned above is actually performed a action so let’s see what Fastlane a total of action, action and how to use
Fastlane actions on the command line can list all the action related information using the Fastlane [action name action] can view the action the most important is https://docs.fastlane.tools/actions/.
in the use of methods to help in the document here can view specific action and shows the list of all action

IOS package publishing tool Fastlane junior Raiders
Paste_Image.png

View the description of a action

IOS package publishing tool Fastlane junior Raiders
Paste_Image.png

page documentation about cocoapods, the action description:

IOS package publishing tool Fastlane junior Raiders
screen snapshot 2016-12-05 a.m. 1.11.49.png

3. write your own lane

Knowing action and lane, let’s go back to the Fastfile file and see how many Lane have been written to us in the generated file

Desc "Runs all the tests Lane test do scan end desc:" Submit a new Beta Build to Apple TestFlight "desc" This will also make sure the profile is up to date Lane beta do match: # (type: Appstore) more information: https:// codesigning.guide gym # # Build your app - more options available pilot # sh "your_script.sh" You also use other # can beta testing services here (run `fastlane actions`) end

There are 2 lane, a beta named test, test in the implementation of scan the action, this is a action used to run the unit test, the specific information you can use the Fastlane action scan view, and then beta the lane implementation of gym and pilot, gym is packaged, pilot is applied to TestFlight the use of specific methods, to view the document.
, but the generated lane may not meet our needs. Here’s an example of an enterprise version package, and we’ll build a new lane for ourselves:

Desc package: inhouse Enterprise Edition IPA Lane do |options| info plist ENV[# update file "key" represents the value read from the environment variable, can also write directly to death, if you want to change some parameters in the package, they can be set to the environment variable update_info_plist (plist_path: "GoodFolks/info.plist" display_name: "App the name" #) update urlType specific usage query action update_info_plist file that update_info_plist xcodeproj: ("GoodFolks.xcodeproj plist_path:", "GoodFolks/info.plist", block: lambda {|plist| # here I'm updating WeChat urlType the action can also update the app specific bundleid can refer to the document urlScheme = plist["CFBundleURLTypes"].find{|scheme| scheme[C " "FBundleURLName" = "Weixin"} urlScheme[: CFBundleURLSchemes] = ENV["app_urlschems_weixin"]}) # set the version number increment_version_number (version_number: ENV["app_versionName"]) # set build number, which can be written to death, can not be the action, you can also get the value from the environment variable increment_build_number (build_number: ENV[app_versionCode "this is very important #)] action cert is to download and install the Profile file, Provision, you don't have to the certificate does not match the thing, download the file there will be the root directory of the project under the build folder (cert output_path: build) # this step is the signature of sigh (app_identifier: ENV[" app_applicationId "" team_id: 9M8C " "TWAV8P, output_path:" build ") # finally is packaged, enterprise edition package, package is completed will generate an IPA gym file in the root directory of the project under the build folder (scheme:" GoodFolks "export_method:, enterprise", "output_directory:", "build include_bitcode: false do some other stuff here) # end

4. take off,
says so much, but how to run?
is very simple in your root directory of the project execution Fastlane [lane name] like a Fastlane inhouse which we write, Fastlane will execute the specified task, then you can go to drink coffee.

Tips
Fastlane may need to interact as input your Apple ID password when packaging, but obviously when sustained release are not automated, interactive shell, no way to manually enter the password, the only need to put your Appleid password into an environment variable, environment variable the key is FASTLANE_PASSWORD.