Read the originalAuthor: Cen Zhijun

Normal product development is completed, we all need to pack testers, and test, and production package, a package needs to be a waste of time for more than ten minutes, and even sometimes, you just finished packing, need to fine tune the product come over to tell you a place (sesame egg, whether want to kill him this time), but can’t, so we have to change the bug, continue to packaging, It can be a morning or an afternoon wasted, so having a tool that can automate packaging not only saves us a lot of time, but also allows us to install… (That’s the point)

In fact, there are many automated packaging tools, the most popular ones are Jenkins and Fastlane. I tried Jenkins before, but I felt that Jenkins was a cumbersome tool, which required a lot of things to configure, warehouse address and so on. Unlike Fastlane, it felt stupid and very simple. There are now over 20,000 stars on Github and a large team of people, so let’s get down to business!!

Preparations before installation

  1. First, check whether ruby is installed. Check the Ruby version on the terminal
ruby -v
Copy the code
  1. Check whether the Xcode command line tool is installed
xcode-select  --install
Copy the code

If there is a

If:

Just click install…

Now you’re ready to install FastLane

Installation steps

  1. Install the fastlane
sudo gem install fastlane
Copy the code
  1. Switch to project directory initialization
fastlane init
Copy the code

The following options appear during initialization:

The first option means: Auto screenshot. The second option means: Automatically publish beta for TestFlight. The third option means: automatically publish to the APP Store. The fourth option means: set manually

I chose the fourth one here (you can choose according to your own needs), as shown in the screenshot below:

Then keep clicking Enter, and the following screenshot will appear after the installation is successful

When the installation is successful, a fastlane folder will be generated in our project directory:

Then we need to edit Appfile and Fastfile ourselves:

First look at the Appfile file, mine is as follows:

Then the Fastfile file:

Firim is specified to upload to fir, if you just want to type out the package can not write a line.

That way, it can be packed smoothly… Execute the package command:

fastlane betaDebug
Copy the code

The following is a screenshot of successful packaging:

Automatically upload tofirOr dandelions

However, if you want to upload your packed package directly to a FIR or dandelion platform, please follow these steps:

Run the following command to install the FIR plug-in:

fastlane add_plugin fir
Copy the code

To automatically upload to fir, execute the following commands:

gem install fir-cli
Copy the code

For dandelion platform, install the following plug-in:

fastlane add_plugin pgyer
Copy the code

The Fastlane folder will now have the following structure: Note that the package folder is generated the first time you package it

At this point, execute the packaging command, can be automatically packaged, and uploaded to the FIR.

After the Pluginfile is installed, the Pluginfile file looks like this: (Note: the plugins you installed will be displayed in this file)

The screenshot of fir successfully uploaded is as follows:

The generated IPA package and DYSM file are as follows:

At this point, the automated packaging and installation process is over, and the pits I encountered are recorded below.

In the pit of

  • A wrong

The reason I have this problem is that the certificate does not match. Modify the Fastfile file and check the export_method parameter to see if it matches…

  • Error 2

The errors are obvious, so please remember: always follow the name you wrote

  • Error of three

The package is successful, but the fir has been uploaded to fail to remember the screenshot, probably the error message is as follows:

Could not find action, lane or variable 'firim'
Copy the code

I was looking at the document and saw that someone had dragged the Gemfile and gemfile. lock files into the FastLane folder, but the automatic generation is outside this folder, but I want to put it in a folder for easy management, so remember, you can put it wherever it was generated.

The firim action could not be found. You can check whether the firim action is installed under the terminal

fastlane actions [firim]
Copy the code

If it is installed, the following is displayed:

If it is not installed, it will prompt that it is not found. At this point, just reinstall the plug-in.

Shell Script packaging

In addition to some open source frameworks, I used to use shell script packaging, nothing more than to write a script, which contains a lot of packaging commands, but still feel that fastlane is not simple and convenient, interested in GitHub can refer to this, write more detailed

conclusion

This is the end of automated packaging in Fastlane, but the fastlane website provides a lot of syntax for those who are interested in it. Also, since I started using it recently, I usually use Fastlane when I pack testers. When it comes time to go online and submit to the AppStore, I’m still going to use Xcode. Submitted to the App Store has not used, there is what pit I don’t know, if someone has done it, welcome to the comments section to communicate with each other (also, think it is good, please like ❤️❤️❤️!! Ha ha)

Knowledge Collection is an official account of the team, mainly in the field of mobile development, sharing mobile development technology, including iOS, Android, mini program, mobile front end, React Native, WEEx, etc. Every week there will be original articles to share, our articles will be in the public number first. Stay tuned for more content.