文档

​
​

Development

User Acquisition

Monetization

工业

Build Automation

DevOps

Build Automation REST API

Build Automation Editor Package

Open Unity Dashboard

Build Automation

​
​
Build Automation
  • Overview
  • Get started with Build Automation
  • Build Automation Glossary
  • Build configuration
  • Advanced build configuration
    • Build Addressables using Build Automation
    • Run custom scripts during the build process
    • Specify the scene to build
    • Customize Fastlane configurations for iOS builds
    • Configure dedicated server build target
    • Use environment variables
  • Run builds
  • Check build results
  • Optimize build speed
  • Manage consumption costs
  • Sign build artifacts
  • Build Automation integrations
  • Build Automation API
  • Build Automation Editor Package
  • Reference
  1. Unity Build Automation
  2. Advanced build configuration

为 iOS 构建自定义 Fastlane 配置

Configure Fastlane settings for iOS builds to control build behavior.
阅读时间5 分钟
最后更新于 10 个月前

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
。该文件支持以下属性(所有这些属性都是可选的,如果不使用某个属性,可将其完全移除):fastfile - 自定义 Fastfile 相对于代码仓库根目录的路径。gymfile - 自定义 Gymfile 相对于代码仓库根目录的路径。lanes - 上述 Fastfile 中的通道。pre_build - 在实际 Xcode 构建步骤之前运行的通道。post_build - 在实际 Xcode 构建步骤之后运行的通道。
这些路径均相对于项目的根目录。
示例
"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.json
中指定的“fastfile”路径相匹配。
如果您配置了 pre_build/post_build 通道,当这些通道运行时,会向其传递一个选项哈希,其中包含:project_dir - 此项目构建所基于代码仓库的根目录。build_target - 此构建的构建目标标识符。output_directory - Xcode 项目将构建至的最终输出目录。
在此示例中,我们在代码仓库的“Assets/ucb/Stickers.mobileprovision”处安装资源调配配置文件,并更新 Xcode 项目中的“Unity-iPhone-Stickers”目标以使用该配置文件。
示例
Assets/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-ca6c48a53a96
的 UUID(即
Assets/ucb/Stickers.mobileprovision
处资源调配配置文件的 UUID)。
示例
Assets/ucb/Gymfile
:
(Ruby)export_options( provisioningProfiles: { "com.unity3d.buildautomation.base.stickers" => "1e33640e-9a55-4357-a632-ca6c48a53a96" })

更新高级设置

最后,在 Dashboard 中更新构建目标的高级设置。
  1. 导航到 Unity Dashboard
  2. 选择 DevOps > Build Automation > Configurations(配置)。
  3. 导航到 iOS 构建目标。
  4. 选择 Edit(编辑)。
  5. 导航到 Edit Advanced Options(编辑高级选项)选项卡。
  6. 在 Platform specific settings (iOS)(针对特定平台的设置 (iOS)) 选项下,设置 Custom Fastlane Configuration Path(自定义 Fastlane 配置路径),该路径相对于项目的根目录。在此示例中,该路径设置为“Assets/ucb_xcode_fastlane.json”。
"为 iOS 构建自定义 Fastlane 配置"

为 iOS 构建自定义 Fastlane 配置


Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • 添加所需文件

      • 文件 1:一个 JSON 选项文件,用于控制自定义 Fastfile/Gymfile 的路径以及应该运行 Fastfile 中的哪些通道。

      • 文件 2:一个自定义 Fastfile,用于安装资源调配配置文件并更新 Xcode 项目中的资源调配设置。

      • 文件 3:一个自定义的 Gymfile,用于在自定义导出选项时定义应用程序标识符到资源调配配置文件的映射。

    • 更新高级设置


报告此页面的问题