为 iOS 构建自定义 Fastlane 配置
Configure Fastlane settings for iOS builds to control build behavior.
阅读时间3 分钟最后更新于 19 天前
Build Automation 依赖 Fastlane 来构建 Xcode 项目。本文档介绍了如何使用名为 Gymfile 的 Fastlane 文件格式来修改 Fastlane 的行为。所有配置选项都与 Fastlane 高度相关,因此建议对工具集有一定的基本了解。 本节以一个基本示例来说明当前如何配置项目以使用多个配置文件进行构建。以下示例假设您正在构建一个应用程序标识符为
"com.unity3d.buildautomation.base""com.unity3d.buildautomation.base.stickers"添加所需文件
此设置目前需要向代码仓库中添加三个额外的文件:文件 1:一个 JSON 选项文件,用于控制自定义 Fastfile/Gymfile 的路径以及应该运行 Fastfile 中的哪些通道。
此文件可以放在代码仓库中的任何位置,但在此示例中放在Assets/ucb_xcode_fastlane.json"Assets/ucb_xcode_fastlane.json"(JavaScript){ "fastfile": "Assets/ucb/Fastfile", "gymfile": "Assets/ucb/Gymfile", "lanes": { "pre_build": "use_stickers_profile", "post_build": "" }}
文件 2:一个自定义 Fastfile,用于安装资源调配配置文件并更新 Xcode 项目中的资源调配设置。
此文件可以放在代码仓库中的任何位置,但需要与上面ucb_xcode_fastlane.jsonAssets/ucb/Fastfile(Ruby)lane :use_stickers_profile do |options| profile_path = File.join(options[:project_dir], 'Assets/ucb/Stickers.mobileprovision') FastlaneCore::ProvisioningProfile.install(profile_path) update_project_provisioning( xcodeproj: 'Unity-iPhone.xcodeproj', target_filter: 'Unity-iPhone-Stickers', profile: profile_path )end
文件 3:一个自定义的 Gymfile,用于在自定义导出选项时定义应用程序标识符到资源调配配置文件的映射。
此文件可以放在代码仓库中的任何位置,但需要与上述 ucb_xcode_fastlane.json 中的“gymfile”路径相匹配。有关可用选项,请参阅 Fastlane 文档。 在此示例中,“com.unity3d.buildautomation.base.stickers”应用程序标识符应映射到1e33640e-9a55-4357-a632-ca6c48a53a96Assets/ucb/Stickers.mobileprovisionAssets/ucb/Gymfile(Ruby)export_options( provisioningProfiles: { "com.unity3d.buildautomation.base.stickers" => "1e33640e-9a55-4357-a632-ca6c48a53a96" })
更新高级设置
最后,在 Dashboard 中更新构建目标的高级设置。- 导航到 Unity Dashboard
- 选择 DevOps > Build Automation > Configurations(配置)。
- 导航到 iOS 构建目标。
- 选择 Edit(编辑)。
- 导航到 Edit Advanced Options(编辑高级选项)选项卡。
- 在 Platform specific settings (iOS)(针对特定平台的设置 (iOS)) 选项下,设置 Custom Fastlane Configuration Path(自定义 Fastlane 配置路径),该路径相对于项目的根目录。在此示例中,该路径设置为“Assets/ucb_xcode_fastlane.json”。

为 iOS 构建自定义 Fastlane 配置