Flutter - 解决混合开发iOS脚本打包遇到的问题
使用 Xcode
手动打包是正常的,但是使用脚本打包会报错,错误如下:
The following build commands failed:
PhaseScriptExecution [CP-User]\ Run\ Flutter\ Build\ Script .../Script-C3A097A8FE12FF5F875B057C.sh
flutter build ios --release
then re-run Archive from Xcode.
Command PhaseScriptExecution failed with a nonzero exit code
# 定位错误
到 Flutter
环境目录下,按图上所示地址找到 xcode_backend.sh
,也可以直接看 官方脚本链接 (opens new window)
# Archive builds (ACTION=install) should always run in release mode.
if [[ "$ACTION" == "install" && "$build_mode" != "release" ]]; then
EchoError "========================================================================"
EchoError "ERROR: Flutter archive builds must be run in Release mode."
EchoError ""
EchoError "To correct, ensure FLUTTER_BUILD_MODE is set to release or run:"
EchoError "flutter build ios --release"
EchoError ""
EchoError "then re-run Archive from Xcode."
EchoError "========================================================================"
exit -1
fi
# 解决方案
可以看到,官方脚本的说明里面给出两个解决方案
方案一:直接设置
FLUTTER_BUILD_MODE
为release
方案二:先运行
flutter build ios --release
,再使用Xcode
去打包
这里我们是用 Jenkins
脚本进行打包,所以方案二不适用,方案一更加方便些
# 设置Flutter的编译模式为release
export FLUTTER_BUILD_MODE=release
# 执行原有项目的打包脚本
./script/build_iOS.sh
上次更新: 2024/11/24, 11:42:29
- 01
- Flutter - 子部件任意位置观察滚动数据11-24
- 02
- Flutter - 危!3.24版本苹果审核被拒!11-13
- 03
- Flutter - 轻松搞定炫酷视差(Parallax)效果09-21