preface

It is a normal process to package tests for test students in daily development work, but every time the test package is generated through Xcode Archive and then exported, and then uploaded to the three-party test website (dandelion, FIR, etc.), I feel nothing. But again and again to repackage, after all the repetition of meaningless work, will feel very tired, so I thought of using automatic packaging to achieve this work.

What is Fastlane?

Fastlane is a very useful and powerful set of components. It is an automated toolset and framework written in Ruby that is designed to be the easiest way to automate test deployment and distribution for iOS and Android applications. It handles all the tedious tasks, such as generating screen shots, handling code signing, and publishing applications.

Installation and use process

1, install,

Sudo gem install Fastlane-nv brew Cask install Fastlane Used before Taobao mirror partners need to replace Ruby China mirror. The installation process may take a while. Please be patient.

2. Initialize Fastlane

CD to the item you want to automate packaging

If your appleID belongs to more than one developer account, select a press enter to continue, and then return the prompt to enter the password and two-factor authentication, as prompted to enter.

3. Set related configuration files

If the above steps go well, your project will have a new Fastlane folder, as shown in the figure below.

Let’s add a lane here that we need for ourselves.

desc "Pack to PGY"
  lane :test do |options|
  gym(
    clean:true.Clean projects before packing
    export_method: "development".# Export method
    scheme:"shangshaban".#scheme
    configuration: "Debug".# environment
    output_directory:"./app".# ipA directory
    output_name:get_build_number(),Output ipA file with the current build number
    # Xcode9 will not allow you to access the contents of the keystring unless allowProvisioningUpdates is set
    export_xcargs:"-allowProvisioningUpdates".# Hide unnecessary information
    silent:true.Note that the packaging method must be set using method in export_options, not export_method
    export_options: {
        method:"development",
        provisioningProfiles: {
            "xxxxxx":"xxxxxx"."xxxxxxx":"xxxxxxx"
            },
        }
    )

  pgyer(api_key: "xxxxx", user_key: "xxxx",update_description: options[:desc])
  end
Copy the code

How to obtain the dandelion API_key and user_key. You need to specify how to obtain the provisioningProfiles data, in Xcode click on Product — “archive” :

Fill in the values corresponding to the provisioningProfiles in the red box above. Then enter fastlane add_plugin pgyer install dandelion plug-in:

4. Run the package and upload

Error “Fastlane test” :