fastlane init项目工程的根目录

本文介绍了如何使用fastlane工具进行iOS应用的自动化打包,包括以development、ad-hoc和app-store方式,并详细展示了Fastfile中的配置脚本,用于上传ipa包到蒲公英和iTunes Connect。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

初始化过程中会让你输入苹果开发者账号的账号和密码,这个信息会存储在钥匙串中,后续使用无需再输入密码。


初始化过程中还会检测当前项目的 App Identifier 是否已经在 Apple Developer 中,还会检测当前 App 是否已经在 iTunes Connect 中,如果都满足的话,过程应该是比较顺利的。


初始化完成之后会在你项目工程的目录下生成一个 fastlane 文件夹,里面是 Fastlane 的一些配置文件。其中 Appfile 里面存放了 App 的基本信息包括 App_Identifier 、AppID 、Team_ID 等。Fastfile 是最重要的一个文件,在这个文件里面可以编写和定制我们打包脚本的一个文件,所有自定义的功能都写在这里


使用编辑器打开 Fastlane 文件,将所有内容删除替换为以下内容。


fastlane_version "2.101.1"

default_platform :ios

platform :ios do

  desc "以 development 方式打包并上传到蒲公英"
  lane :test_beta do

    puts "以 development 方式打包"
    gym(
      # 指定打包所使用的输出方式 (可选: app-store, package, ad-hoc, enterprise, development)
      export_method: "development",
      # 指定项目的 scheme 名称
      scheme: "xxx",
      # 指定输出的文件夹地址
      output_directory: "./archive/test_beta/" + Time.new.strftime("%Y-%m-%d-%H:%M:%S"),
    )

    puts "上传 ipa 包到蒲公英"
    pgyer(
      # 蒲公英 API KEY
      api_key: "xxx",
      # 蒲公英 USER KEY
      user_key: "xxx"
    )

  end

  desc "以 ad-hoc 方式打包并上传到蒲公英"
  lane :beta do
    puts "自动生成 Provisioning Profiles 文件"
    sigh(
      # 指定输出的文件夹地址
      output_path: "./archive/sign",
      # 是否为 AdHoc 证书(设为 false 或不写默认为 AppStore 证书)
      adhoc: true
    )

    puts "以 ad-hoc 方式打包"
    gym(
      # 指定打包所使用的输出方式 (可选: app-store, package, ad-hoc, enterprise, development)
      export_method: "ad-hoc",
      # 指定项目的 scheme 名称
      scheme: "xxx",
      # 指定输出的文件夹地址
      output_directory: "./archive/beta/" + Time.new.strftime("%Y-%m-%d-%H:%M:%S"),
      # 指定打包方式 (可选: Release, Debug)
      configuration: "Release"
    )
    puts "上传 ipa 包到蒲公英"
    pgyer(
      # 蒲公英 API KEY
      api_key: "xxx",
      # 蒲公英 USER KEY
      user_key: "xxx"
    )

  end

  desc "以 app-store 方式打包并上传到 iTunes Connect"
  lane :release do

    puts "自动生成 Provisioning Profiles 文件"
    sigh(
      # 指定输出的文件夹地址
      output_path: "./archive/sign"
    )

    puts "以 app-store 方式打包"
    gym(
      # 指定打包所使用的输出方式 (可选: app-store, package, ad-hoc, enterprise, development)
      export_method: "app-store",
      # 指定项目的 scheme 名称
      scheme: "xxx",
      # 指定输出的文件夹地址
      output_directory: "./archive/release/" + Time.new.strftime("%Y-%m-%d-%H:%M:%S"),
      # 指定打包方式 (可选: Release, Debug)
      configuration: "Release"
    )

    puts "上传 ipa 包到 iTunes Connect"
    deliver(
      # 跳过截图上传
      skip_screenshots: true,
      # 跳过元数据上传
      skip_metadata: true,
      # 跳过审核直接上传
      force: true
    )

  end

end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值