Fastlane is a set of automation tools and frameworks written in Ruby language. Each tool corresponds to a Ruby script, which is used to perform a specific task. The Fastlane core framework allows users to combine different tools organically and flexibly in the form of similar configuration files. Thus forming a complete automated process.

Install Fastlane first

sudo gem install fastlane --verbose
Copy the code

Make sure Xcode has the latest version of the command line tool installed

xcode-select --install
Copy the code

If Fastlane loads slowly, try running it

gem clean up

Copy the code

Find the item root directory

cd /Users/jsqb/Desktop/iOS
Copy the code

Perform fastlane installation

Run fastlane init to configure the developer accounts user, password, and bundle identfierCopy the code

Fastlane files are generated

Appfile - contains your app_id bundle ID. If you entered the correct appId and password in init last step, this will generate the correct team_id information here. Fastfile - is the most important file to write and customize our package scriptCopy the code

Fastlane tools

In addition to the Fastlane command, you can also access the following Fastlane tools

  • Deliver: Upload screenshots, metadata, and app applications to the App Store
  • Supply: Upload Android app apps and metadata to Google Play
  • Snapshot: Automatically captures local snapshots of iOS app applications
  • Screengrab: Automatically captures local screenshots of Android app applications
  • Frameit: Quickly take a screenshot and place it on the device
  • Pem: Automatically generates and updates the push notification configuration file
  • Sigh: Development certificate and description file download
  • Produce: Create new apps and development portals on iTunes Connect using the command line
  • Cert: Automatically creates and configures iOS code signing certificates
  • Spaceship: Ruby library access Apple Developer Centre and iTunes Connect
  • Pilot: The best way to manage your TestFlight testers and build from the terminal
  • The easiest way to invite your TestFlight beta testers
  • Gym: automatic iOS app signature packaging tool
  • Match: Use Git to synchronize your team certificates and configuration files
  • Scan: The easiest way to test your iOS and Mac apps

We use gym for automatic packaging

Add the. Env file to the fastlane file. The content of the configuration file can be expanded as follows

Env global configuration file
# bundleId
APP_IDENTIFIER = "com.xqb.R"

# Dandelion, updated description
PGY_UPDATE_DESCRIPTION = "3.0.0 Test Pack"

# Automatically submit for review
SUBMIT_FOR_REVIEW = false

Publish as soon as approved
AUTOMATIC_RELEASE = false

# Apple Developer account
APPLE_ID = "[email protected]"

# Apple Developer account password
FASTLANE_PASSWORD = "xxxxx"

# suits ID
TEAM_ID = "xxxx"

# APP metadata and screenshot storage path
METADATA_PATH = "./metadata/TestGitProject"
SCREENSHOTS_PATH = "./screenshots/TestGitProject"

# APP metadata and screenshots download, directly overwrite the original data, without asking
DELIVER_FORCE_OVERWRITE = true

# the package name
SCHEME = "KDFDApp"

Specify the packaging method, Release or Debug
CONFIGURATION = "Debug"

# Specify the output method used for packaging, currently supporting app-Store, package, ad-hoc, Enterprise, and Development
EXPORT_METHOD = "enterprise"

# Dandelion API Key is provided by dandelion platform
PGY_API_KEY = "xxxx"

# dandelion API Key
PGY_USER_KEY = "xxxx"
Copy the code

Appfile File content

app_identifier ENV['APP_IDENTIFIER']
apple_id ENV['APPLE_ID']
team_id ENV['TEAM_ID']
Copy the code

Deliverfile file contents

app_identifier ENV['APP_IDENTIFIER']
username ENV['APPLE_ID']
Copy the code

Install the Fastlane plugin for Dandelion

Enter Astlane add_plugin pgyerCopy the code

Add it to the generated Gemfile file

gem 'cocoapods'
Copy the code

Finally, we write a Fastlile file to run the script

desc "Release the beta version to dandelion"
lane :qb_pgy do
gym(scheme: ENV['SCHEME'],
silent: true.# Hide unnecessary information
include_symbols: true.# whether to generate a symbol table. Default is true
include_bitcode: true.Whether to enable bitcode. Default is true
clean:true.# Whether to clear previous compilation information true: Yes
configuration: ENV['CONFIGURATION'],
export_method: ENV['EXPORT_METHOD'],
output_name: Speed Wallet.# output file name
output_directory: "./fastlane/bulid") # specify the output folder
pgyer(api_key: ENV['PGY_API_KEY'],
user_key: ENV['PGY_USER_KEY'],
update_description: ENV['PGY_UPDATE_DESCRIPTION'])
end
desc "Pack the official version"
lane :qb_appStore do
gym(scheme: ENV['SCHEME'],
output_name: Speed Wallet.The ipA name to output
silent: true.# Hide unnecessary information
clean: true.Clean before building
configuration: "Release".Configure the Release version
codesigning_identity: "iPhone Distribution: Shanghai Peijun Information Technology Co., Ltd. (DFB9QG8MBN)".# code signing certificate
buildlog_path: "./fastlane/onLine/fastlanelog".Fastlane build ipA log output directory
output_directory: "./fastlane/onLine")
end
Copy the code

After the preparation of the certificate in the project to choose the right, we can be in the terminal through Fastlane + dandelion can be automated packaging release function

fastlane qb_pgy
Copy the code

Finally, it took 74s to upload successfully

This part of the automation file does not need to be submitted to the remote server, we added the ignore information in the gitignore file

*fastlane/
Copy the code

Various automated processes can be customized with FastFile.