fastlane iOS官方翻译四 (生成测试包)

2019-05-29  本文已影响0人  渐行渐远ty

使用fastlane打包iOS测试版本

打包你的app

fastlane使用名叫build_app的action来打包你的app,添加如下代码到你的Fastfile:

lane :beta do
  build_app(scheme: "MyApp")
end

你可以添加更多的参数来构建你的app,举例

lane :beta do
  build_app(scheme: "MyApp",
            workspace: "Example.xcworkspace",
            include_bitcode: true)
end

你可以使用下面代码来执行

fastlane beta

如果成功了,你可以在当前目录下找到一个[产品名称].ipa.获取更多相关参数可以执行fastlane action build_app.

签名

如果你在上一步因为签名而导致失败,我们准备了签名向导帮助你设置你应用的签名.

上传你的app

在你构建完成你的app后.它将根据你的选择上传你的测试版本.fastlane的长处在于可以轻松的更换测试提供者,或者一次上传至多处而不要更多的工作.

你所要做的只是把测试提供者的名字列举在你的build_applane中:

lane :beta do
  sync_code_signing(type: "appstore")    # see code signing guide for more information
  build_app(scheme: "MyApp")
  upload_to_testflight
  slack(message: "Successfully distributed a new beta build")
end

fastlane会自动的将.ipa的相关信息从build_app中发送至你选择的测试提供者.

获取所有可用参数你可以:

fastlane action slack

Beta测试提供者

lane :beta do
  # ...
  build_app
  upload_to_testflight
end

一些例子

lane :beta do
  # ...
  build_app

  # Variant 1: Provide a changelog to your build
  upload_to_testflight(changelog: "Add rocket emoji")

  # Variant 2: Skip the "Waiting for processing" of the binary
  #   While this will speed up your build, it will not distribute
  #   the binary to your tests, nor set a changelog
  upload_to_testflight(skip_waiting_for_build_processing: true)
end

如果你使用fastlane init 设置fastlane,你的appID存储在fastlane/Appfile中.你也可以重写用户名使用upload_to_testflight(username: "bot@fastlane.tools").

获取可用参数你可以

fastlane action upload_to_testflight

你也可以使用fastlane自动管理你的测试者.

lane :beta do
  # ...
  build_app
  crashlytics(api_token: "[insert_key_here]",
              build_secret: "[insert_key_here]")
end

你可以通过组织设置页面获取你的API key 和secret links.

获取更多可用参数

fastlane action crashlytics
lane :beta do
  # ...
  build_app
  hockey(api_token: "[insert_key_here]")
end

可以在API Tokens账户设置获取你的API token.

发布标注

你可以更改日志,这样就不需要太多的语句存储在Fastfile中.

lane :beta do
  sync_code_signing
  build_app

  changelog_from_git_commits # this will generate the changelog based on your last commits
  upload_to_testflight
end

更多的例子:

changelog_from_git_commits(
  between: ['7b092b3', 'HEAD'], # Optional, lets you specify a revision/tag range between which to collect commit info
  merge_commit_filtering: exclude_merges # Optional, lets you filter out merge commits
)
lane :beta do
  # Variant 1: Ask for a one line input
  changelog = prompt(text: "Changelog: ")

  # Variant 2: Ask for a multi-line input
  #   The user confirms their input by typing `END` and Enter
  changelog = prompt(
    text: "Changelog: ",
    multi_line_end_keyword: "END"
  )

  sync_code_signing
  build_app

  upload_to_testflight(changelog: changelog)
end

[https://www.jianshu.com/p/2a029dda5337](fastlane iOS官方翻译五 (生成正式包))

上一篇下一篇

猜你喜欢

热点阅读