今是昨非

今是昨非

日出江花红胜火,春来江水绿如蓝

iOS Automatic Packaging

iOS Automatic Packaging#

Using FastLane for Packaging#

Installing fastlane#

  • Install via HomeBrew
    brew install fastlane

  • Install via Bundler

    1. Install bundler
    2. Then create a ./Gemfile file in the project root directory and edit its contents

// Install bundler
$ gem install bundler


// Then create a ./Gemfile file in the project root directory and edit its contents
source "https://rubygems.org"
gem "fastlane"

Edit the Gemfile file:


source "https://rubygems.org"
gem "fastlane", "2.180.1"
# If using Cocoapods, add the following line
gem "cocoapods"

  • Install via ruby gems
sudo gem install fastlane

After successful installation of fastlane, install two plugins for version management and uploading to corresponding third-party platforms after successful packaging

// Add fastlane plugins
// Refer to the usage of versioning at https://github.com/SiarheiFedartsou/fastlane-plugin-versioning for version number retrieval and modification
// firim is the plugin for the fir platform

fastlane add_plugin versioning
fastlane add_plugin fir_cli # https://github.com/FIRHQ/fastlane-plugin-fir_cli


// pgyer is the plugin for the pgyer platform
// fastlane add_plugin pgyer

Editing fastlane content#

Refer to the fir platform's firim related parameters: Link. At least the firim_api_token parameter is required, which can be obtained from your own registered firim, or you can configure the following parameters

  • firim_api_token
  • app_name
  • app_desc
  • app_passwd
  • app_version
  • app_build_version
  • app_changelog
  • and so on

Edit the Fastfile and define an Action named TestFir. Specify the output package name as (version number + time), and after packaging, the package will be placed in the ./build directory and uploaded to fir. As follows


default_platform(:ios)

platform :ios do
  desc "Description of what the lane does"

  lane :TestFir do
    time = Time.new.strftime("%Y%m%d%H%M") # Get the time format, refer to the format at https://www.runoob.com/python/att-time-strftime.html
    # verion = get_version_number_from_list() # Get the version number

    version = get_version_number_from_xcodeproj(build_configuration_name: 'Release') # Refer to the GitHub link for usage, https://github.com/SiarheiFedartsou/fastlane-plugin-versioning

    ipaName = "Release_#{version}_#time.ipa" # Format of the generated ipa package name

    gym(
      clean: true, # Clean the project before packaging
      silent: true, # Hide unnecessary information
      scheme: "Your Scheme Name", # Specify the scheme name of the project
      export_method: "ad-hoc", # Type of packaging: ad-hoc, enterprise, app-store, development
      configuration: "Release", # scheme: Default is Release, also Debug
      output_name: "#{ipaName}", # Output package name
      output_directory: "./build" # Output location
    )
    # Your own fir account, configuration details can be found at https://github.com/FIRHQ/fastlane-plugin-fir_cli
    fir_cli api_token: "xxx",  changelog: "My First Fir Upload"
    # Configuration for pgyer, replace with your own api_key and user_key
    # pgyer(api_key: "******", user_key: "******",update_description: options[:update_info])
  end

end

To use, enter fastlane TestFir in the command line

fastlane TestFir

If you want to pass parameters from the outside when executing the command, you can use the following method. Add |options| after do, and use options[] to obtain the value passed from the outside

lane :ActionName do |options|
    gym(
      configuration: options[:configuration],# Environment
      )
    
    # Your own fir account
    fir_cli api_token: "xxx",  changelog: options[:changelog]
  end

The way to call from the outside is as follows:

fastlane ActionName configuration:"adhoc" changelog:"first submit"

Packaging with Jenkins, to be continued#

References#

iOS Automatic Packaging with fastlane + fir + pgy [Advanced Usage]

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.