Fastlane (Automated packaging)

Installation:

sudo gem install -n /usr/local/bin fastlane
Copy the code

1. In the project directory, the Fastlane folder is generated in the project directory

fastlane init
Copy the code

You will then be asked to enter your developer id and password

Custom fastFile file writing

  • AppStore version
# You can define as many lanes as you want
desc "Deploy a new version to the App Store"
lane :release do |op|
    increment_version_number(version_number: op[:version]) Get the app version number from the input parameter version
    increment_build_number(build_number: op[:version])  # set the build number to the same as the app version number

    # Set the app info.plist file entry
    set_info_plist_value(path: "./xxx/Info.plist".#info.plist file directory
                        key: "UIFileSharingEnabled".# key, open the plist file in the form of Source Code to query the corresponding key
                        value: false)  # value

    # set up a custom plist file item, which is used to configure different server urls for app
    set_info_plist_value(path: "./xxx/hostAddress.plist",
                        key: "host",
                        value: "https:/zhengshiServer:xx/xxx/xxx")

    # Update Provisioning Profile
    Create the Provisions folder in the project's current directory and save the.mobileprovision file for the App Store version in it, name it whatever you want.
    update_project_provisioning(profile: "./provisions/appstore.mobileprovision")

    # Update the project team
    update_project_team(path: "xxx.xcodeproj",
                  teamid: "5JC8GZ432G")

    # Start packing
    gym(use_legacy_build_api: true,
        output_name: "appstore".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: xxx Co.,Ltd. (5JC8GZ432G)".# code signing certificate
        buildlog_path: "./fastlanelog".Fastlane build ipA log output directory
        output_directory: "/Users/xxx/Desktop")  # ipA output directory

end
Copy the code
  • Test version
desc "Build a new version use the ceshi"
lane :ceshi do |op|
    increment_version_number(version_number: op[:version])
    increment_build_number(build_number: op[:version])

    set_info_plist_value(path: "./xxx/Info.plist",
                        key: "UIFileSharingEnabled",
                        value: true)

    set_info_plist_value(path: "./xxx/hostAddress.plist",
                        key: "host",
                        value: "https:/ceshiServer:xx/xxx/xxx")

    Save the Development version of the. Mobileprovision file with an arbitrary name.
    update_project_provisioning(profile: "./provisions/development.mobileprovision")

    update_project_team(path: "xxx.xcodeproj",
                  teamid: "5JC8GZ432G")

    gym(use_legacy_build_api: true,
        output_name: "ceshi",
        silent: true,
        clean: true,
        configuration: "Debug",
        buildlog_path: "./fastlanelog",
        codesigning_identity: "iPhone Developer: xxx (xxxxxxxxxx)",
        output_directory: "/Users/xxx/Desktop"
  )
end
Copy the code
  • Batch processing
desc "build all version ipa"
lane :all do |op|
    t = op[:version]
    ceshi version:t
    release version:t
end
Copy the code

Run the ipA command to output the ipA

Fastlane Release version:1.0.0 fastlane Release version:1.0.0 App Store ipA Fastlane All Version :1.0.0 // Pack CESHI, App Store version IPA, app version 1.0.0Copy the code

Finally successful solution eg:

Fastlane automatic packaging

AD – hoc version:

desc "Build a new version use the ceshi"
lane :ceshi do|op| increment_version_number(version_number: op[:version]) increment_build_number(build_number: Op [: version]) set_info_plist_value (path: ". / XXXX/Info. The plist", # project plist file key:"UIFileSharingEnabledValue: ", true) set_info_plist_value (path: ". / XXXXX/hostAddress plist",
                        key: "host",
                        value: "https://www.xxxx.com/ ") # Save the Development version of the. Mobileprovision file with an arbitrary name. update_project_provisioning(profile: "./xxxxx/provisions/Distribution_adhoc.mobileprovision") update_project_team (path: "XXXX. Xcodeproj",
                  teamid: "9Z4ZJ5K398")

    # Start packing
    gym(# use_legacy_build_api: true,
	scheme: "xxxxxxx",
        output_name: “xxxxxx”,  The ipA name to output
        silent: true.# Hide unnecessary information
        clean: true.Clean before building
        configuration: "Debug".Configure the Release versionCodesigning_identity: "iPhone Distribution: XXXXXX Network Technology Co., Ltd. (9Z4Zj5K398)",# code signing certificateExport_method: 'AD hoc',# Specify the output method to use for packaging, currently supporting app-Store, package, ad-hoc, Enterprise, Development, and developer-ID, the method parameter for XcodeBuild
        buildlog_path: "./fastlanelog".Fastlane build ipA log output directory
        output_directory: "./fastlane")  # ipA output directory
end
Copy the code

Problems with Fastlane

  • 1. The gem path cannot be found —- Uninstall fastlane and reinstall it
  • 2. Turn off Bitcode
  • 3. Manually manage certificates
  • 4. Fastfile issues
      • 1. Configure the projectInfo.plistThe path
      • 2. NewhostAddress.plistAnd configure the path (function is to set the server address)
      • 3. AddmobileprovisionConfiguration file (the name and path of the configuration file must be correct)
      • 4. Configure your projectxxxx.xcodeprojteamid(There will be a TeAMID for each developer account)
      • 5.gymThe configuration of the
            gym(# use_legacy_build_api: true,
        Copy the code

    Scheme: “XXXX “, output_name:” XXXXX “, # Output IPA name Silent: true, # Hide unnecessary information Clean: true, # Clean configuration before building: “Debug”, # configure as Release coDesigning_identity: “iPhone Distribution: XXXXX Network Technology Co., Ltd. (9Z4ZJ987368) “, # code signature certificate (found in keystring) export_method: ‘ad-hoc’, # specify the output method used for packaging, Currently supports app-store, package, ad-hoc, Enterprise, development, and developer-ID, that is, xcodeBuild method parameter buildlog_path: Output_directory: “./fastlane”) # ipA output directory