Flutter

Flutter-解决混合开发iOS脚本打包遇到的问题

2020-08-29  本文已影响0人  一意孤行的程序猿

收录:LinXunFeng

使用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,也可以直接看官方脚本链接

  # 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_MODErelease

方案二:先运行flutter build ios --release,再使用Xcode去打包

这里我们是用Jenkins脚本进行打包,所以方案二不适用,方案一更加方便些

# 设置Flutter的编译模式为release
export FLUTTER_BUILD_MODE=release

# 执行原有项目的打包脚本
./script/build_iOS.sh

结交人脉

最后推荐个我的iOS交流群:789143298
'有一个共同的圈子很重要,结识人脉!里面都是iOS开发,全栈发展,欢迎入驻,共同进步!(群内会免费提供一些群主收藏的免费学习书籍资料以及整理好的几百道面试题和答案文档!)

上一篇下一篇

猜你喜欢

热点阅读