You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Codemagic CI/CD中为Flutter的Shorebird配置export_options.plist

Flutter + Codemagic + Shorebird iOS构建:export_options.plist配置问题

问题背景

在使用Codemagic为Flutter项目配置Shorebird iOS CI/CD时,执行shorebird release ios命令时遇到报错:

Export options plist /Users/builder/export_options.plist does not set manageAppVersionAndBuildNumber to false. This is required for shorebird to work.

当前使用的Codemagic脚本片段:

- name: Build for iOS
  script: |
    shorebird release ios \
     --export-options-plist=/Users/builder/export_options.plist \
     --build-name=1.0.2

问题解答

1. 在Codemagic中应将export_options.plist放在何处?

不需要放在系统默认路径(比如/Users/builder/),更推荐放在项目目录内,比如iOS模块的根目录(ios/)或者项目根目录。这样既方便版本控制,也能避免构建环境中路径权限或存在性问题。

2. 是否需放在特定目录还是任意位置?如何确保该文件在构建过程中可访问且创建正确?

  • 没有强制的特定目录要求,只要构建脚本能通过正确路径访问到即可。但优先选择项目内路径,避免依赖Codemagic的临时系统目录(可能存在清理或权限问题)。
  • 确保文件正确的核心要求:必须在plist中添加manageAppVersionAndBuildNumber字段并设为false——因为Shorebird需要自主管理版本号和构建号,不能让Xcode自动修改这些值。

3. Codemagic中创建并使用该文件的示例

有两种常用方式:

方式一:项目中提前添加export_options.plist

在项目的ios/目录下创建export_options.plist,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>manageAppVersionAndBuildNumber</key>
    <false/>
    <!-- 根据你的构建需求添加其他配置,比如method、teamID等 -->
    <key>method</key>
    <string>app-store</string>
    <key>teamID</key>
    <string>你的TeamID</string>
</dict>
</plist>

然后在Codemagic脚本中使用项目内的路径:

- name: Build for iOS with Shorebird
  script: |
    shorebird release ios \
     --export-options-plist=./ios/export_options.plist \
     --build-name=1.0.2

方式二:在Codemagic构建脚本中动态生成

如果不想在项目中添加文件,可以在构建步骤前动态生成该plist文件,比如放在项目根目录:

- name: Generate export_options.plist
  script: |
    cat > ./export_options.plist << EOL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>manageAppVersionAndBuildNumber</key>
    <false/>
    <key>method</key>
    <string>app-store</string>
    <key>teamID</key>
    <string>你的TeamID</string>
</dict>
</plist>
EOL

- name: Build for iOS with Shorebird
  script: |
    shorebird release ios \
     --export-options-plist=./export_options.plist \
     --build-name=1.0.2

Codemagic环境中没有强制的标准配置方式,但以上两种都是经过验证的常用方案,核心是保证plist中包含manageAppVersionAndBuildNumber=false的配置,且脚本能正确访问到文件路径。


内容的提问来源于stack exchange,提问作者Runzun Shrestha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 19:50:04