For the release and launch of an iOS APP, it generally needs to go through: compile and package -> screenshot -> fill in some instructions -> upload IPA to iTunes Connect -> submit for review. There are so many “tedious” steps to go through each time, and for some steps, you need to wait for the interface to indicate an upload error and then manually start again (it’s scary to think about it). In daily development, packaging is also the last online indispensable link, if you need to generate IPA files usually need to click on Product -> Archive in Xcode, and then choose what type of package (AD Hoc/Enterprise) to export from the pop-up Organizer. For large projects that take more than 10 minutes to compile, a few packages a day is almost over. To solve these problems, Felix Krause wrote a toolset called Fastlane. Fastlane is an automated toolset written in Ruby for iOS and Android packaging, publishing, and more.

preface

Shell error: exportArchive: “***. App “requires a Provisioning profile. The same goes for deleting the configuration file and re-downloading it, so I just switched to another scripting tool to package the IPA, and found that it worked pretty well

introduce

  • Fastlane is an automated toolset written in Ruby for iOS and Android packaging, publishing, and more that can save a lot of time.

  • Github:github.com/fastlane/fa… Official website: Fastlane.tools Documentation: docs.fastlane.tools

Configure the environment

  • The first step is to install the correct version of Ruby. Verify with the following command in the terminal window: ruby -v

  • If no, run the sudo gem install gym command to install gym

  • Ensure that the Xcode command line tool has the latest version installed, use the following command to install: xcode-select –install

  • Rubygem: sudo gem install Fastlane

  • Complete the installation

In actual fastlane

Initialize the

  • Open the terminal, CD to your project directory, and execute fastlane init to start the initialization

  • In the process of execution, you will be required to fill in some project information, such as Apple ID, Fastlane will automatically detect the App Name and App Identifier of the project in the current directory, you can choose to enter these information. The initialization will generate a Fastlane folder under the current directory.

  • The two most important files are Appfile and Fastfile, described below

  • Appfile stores the basic information of App, including app_identifier, apple_ID, team_id, etc. If you input the correct apple_id and password during init, team_ID will be automatically obtained.

  • Fastfile is the most important file in which we can write and customize our automation scripts, and all the flow control functions are written in this file.

Fastfile file

Fastfile manages the lanes you create to learn more. It looks like this:
desc "Enterprise Edition"
lane :inHouse do
gym(scheme: "XXX",
export_method:"enterprise",
output_directory "./build".# Directory for storing ipA files after packaging
output_name "XXX"  # ipa filename
)
end
Copy the code

The use of the I

There are four main changes in fastFile

  1. Platform :ios DO (Available for Android and ios)

  2. Desc “ad_Hoc version “(description of Lane, fastlane will automatically document desc’s content)

  3. Lane :beta do (Define a lane (task), which can be interpreted as a function, and we use the Fastlane lane name when executing it, such as CD to the project root directory, then Fastlane beta)

  4. Gym (Scheme :" project name ", export_method:"app-store",output_directory: "./build",)

I usually use gym grammar for operation

gym(scheme: scheme_name, clean: true, export_method:'appstore', configuration: configuration, output_directory: output_directory, output_name: output_name)
Copy the code

The results of

I have just set the check on the gleason’s inside for testing.

# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
# For a list of all available actions, check out``
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
# Specify the output method to be used for packaging, currently supporting app-Store, package, ad-hoc, Enterprise, Development, and developer-ID


default_platform(:ios)

platform :ios do
desc "Ad_Hoc version"
lane :beta do
gym(scheme: "* * *",
export_method:"ad-hoc",
output_directory: "./build".# file path
)
end
end
Copy the code

Upload the ipA package to fir and write to Fastfile:

# This is the minimum version number required.
# Update this, if you use features of a newer version
# Specify the output method to be used for packaging, currently supporting app-Store, package, ad-hoc, Enterprise, Development, and developer-ID



default_platform :ios

platform :ios do


desc "Start packaging - Beta - Development certificate - dev"
# Private beta - Development certificate
lane :adhoc do 
# Start packing
puts "Start packaging - Beta - Development certificate - dev"

gym(
export_method:"ad-hoc",
output_directory:"/Users/weiyuxiang/Desktop/Order/build".# Directory for storing ipA files after packaging
) 
Upload IPA using FIR -cli
sh "Fir the publish/Users/weiyuxiang/Desktop/Order/build / * * *. Ipa -t fir token." "
end

desc "Start packing -- Enterprise Beta -- Hoc"
lane :inhoc do
gym(
export_method:"app-store",
output_directory:"/Users/weiyuxiang/Desktop/Order/build".)Upload IPA using FIR -cli
sh "Fir the publish/Users/weiyuxiang/Desktop/Order/build / * * *. Ipa -t fir token." "
end

end
Copy the code

When using fastlane adhoc in the test, there is generally no problem with using fastlane inhoc in the test. However, there is also a problem with the fir upload, which will report these errors:

/ Users/weiyuxiang /. RVM/rubieslast/ruby - 2.2.4 / lib/ruby/gems / 2.2.0 / gems/fastlane - 2.95.0 fastlane_core/lib/fastlane_core/UI/int erface.rb:153:in `shell_error!': [!]  Exit status of command 'fir publish /Users/weiyuxiang/Desktop/Order/build/***.ipa -T a5bd6574b7292220d5c4b44b6' was 1 instead of 0. (FastlaneCore::Interface::FastlaneShellError) / Users/weiyuxiang /. RVM/gems/ruby - 2.2.4 @ global/gems/bundler - 1.16.1 / lib/bundler/rubygems_integration rb: 458: in ` block in replace_bin_path': can't find executable fir for gem fir-cli. fir-cli is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception) from / Users/weiyuxiang /. RVM/gems/ruby - 2.2.4 @ global/gems/bundler - 1.16.1 / lib/bundler/rubygems_integration rb: 478: in ` block in replace_bin_path'The from/Users/weiyuxiang /. RVM/gems/ruby - 2.2.4 / bin/fir: 22:in `<main>'the from/Users/weiyuxiang /. RVM/gems/ruby - 2.2.4 / bin/ruby_executable_hooks: 15: in ` eval'The from/Users/weiyuxiang /. RVM/gems/ruby - 2.2.4 / bin/ruby_executable_hooks: 15:in `<main>'
Copy the code

Follow the error and add “gem” to Gemfile


There are many more things Fastlane can do, so take a look at the Fastlane documentation and explore some advanced uses.