初始化过程中会让你输入苹果开发者账号的账号和密码,这个信息会存储在钥匙串中,后续使用无需再输入密码。
初始化过程中还会检测当前项目的 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