preface

In our daily development work, it is inevitable that there will be such a scene: after the completion of requirements iteration development, ipA package needs to be provided to QA students for testing. Generally, the following process will be implemented: 1. 2.Pod Install Install the latest dependency library 3. In Xcode, click Archive to compile and package. 4. Choose to export an iOS AdHoc mode ipa file 5. Upload IPA to Fir platform to generate TWO-DIMENSIONAL code for test students to install.

Even if the whole process goes well, it will take the developer 10 to 20 minutes, but if a problem is found during testing, repeat the steps after fixing it. For development students, this kind of repetitive and no technical content of mechanical work is a nightmare ah!

The body of the

So what kind of tools can help developers solve this problem? Here’s a look at Fastlane, a popular automated process tool on the market. 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. So far, Fastlane’s toolset covers packaging, signing, testing, deployment, distribution, library management, and more. The suite also supports integration with Jenkins, CocoaPods, XCTools, and other third-party tools.

With that in mind, let’s take a look at how fastlane can be used in a project.

First step, installation and initialization:

1. Install Xcode Command line Tools

Xcode – select – install

2. Install the fastlane

   sudo gem install fastlane -NV

3. Enter the project path and initialize fastLane (this part can be configured according to actual project requirements)

    fastlane init

3.1. Choose what do you want to do with Fastlane?

3.2. You are required to enter the App ID of the Apple development certificate

3.3. Whether to manage APP metadata

3.4. Press Enter until the initialization succeeds

3.5. File directory structure after initialization




Step 2: Knowledge preparation

1. File introduction

Appfile

Store App information, such as Apple ID, App Identifier, Team ID, etc.

Fastfile

Automated script configuration file where all tasks are scheduled.

.env

ENV[‘Apple_Id’] : ENV[‘Apple_Id’] : ENV[‘Apple_Id’]

Deliverfile

Upload the configuration file required for the AppStore Package. In this file, you can set all the configuration items of AppStore Connect.

metadata

Store APP metadata files, including keywords, version update logs, ICONS, etc.

screenshots

Saving app Screenshots

2. Common tool sets (Actions)

  • Scan (run_tests) : Automatically runs the test tool.
  • Cert (get_certificates) : automatically creates iOS code signing certificates (.cert files) and downloads existing certificate files if they exist.
  • Sigh (get_provisioning_profile) : Download Provisioning Profiles.
  • Gym (build_iOS_app) : compiles, packages, and generates signed IPA files.
  • Deliver (upload_to_app_store) : Uploads the App to App Store Connect.
  • Snapshot (capture_iOS_screenshots) :
  • .

Introduce more action can reference is introduced in the fastlane document: docs. Fastlane. Tools/actions /

3. The lane is introduced

When we wrote the Fastfile file, we actually made FastLane perform the tasks in the desired order by adding the appropriate toolset actions to our custom lanes, although FastLane has some system-level Lanes by default.

System level lane:

  • Before_all is the code that is executed first before executing the script once, in which we can execute common things like git_pull, cocoapods.
  • After_all, after successful completion, processes the common post-logic.
  • Before_each, lane is executed once before each execution.
  • After_each is executed after each lane execution.
  • Error, any environment that reports an error will abort and execute once.

Step 3: Code example

With the above knowledge, let’s take the ipA packet to Fir as an example to see how fastlane automation packaging code is implemented.

Let’s start with the. Env file:



And then the Appfile:



And finally, our FastFile:







Now you can upload the IPA package to the Fir platform via fastlane upload_FIR build:PublicDebug log:update_info.

Of course you can also find our IPA packages, DSYM files, Fastlane package log files and more in our project directory.





conclusion

By using Fastlane to achieve automatic packaging, development students can finally say goodbye to the tedious mechanical work ~

In addition to the features described in this article, Fastlane has more to discover, such as custom actions, plugins, continuous integration, and more. This article is only a primer, I hope you can explore the deeper use of Fastlane.

Finally, this article is mainly for the purpose of stage learning records, will not be used for commercial purposes, if inadvertently infringing, please feel free to contact [email protected].

References:

Fastlane GitHub address: github.com/fastlane/fa…

Fastlane documentation address: docs.fastlane.tools/