概要

在集成flutter 工程之后,我们的工程在debug 和release 模式下都没什么问题,一切都很顺利。但是我们在打企业包的时候却出现了错误:

Showing Recent Errors Only
:-1: ERROR: Unknown FLUTTER_BUILD_MODE: beta_enterprise.

其中,我们的企业包配置如下 Beta_Enterprise

一开始其实我知道flutter里面有:release、debug 和profile 三种打包模式,所以考虑是不是由于 只能支持这三种模式?我们的工程也只能配置Debug、Release和Profile 三种模式?

但是另外一想:其他公司企业版本也很多,如果只支持这三种也太不专业了,因此慢慢研究了其打包脚本的原理,具体处理问题如下。

问题处理

第一步:从我集成flutter工程脚本入手

我使用的是 flutter channel  master  最新的方式集成方式

Podfile 文件配置:

####Flutter###
flutter_application_path = '../../Flutter/flutter_project'. //这里填写的host 工程和flutter工程相对路径
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb') target 'myApp' do
use_frameworks! install_all_flutter_pods(flutter_application_path)
...
end

按住 cmd+B   之后iOS 工程在 Targets-> Build Parses 之中会自动生成 [CP-User] Run Flutter Build Script 这个脚本,脚本内容如下:

set -e
set -u
source "${SRCROOT}/../../Flutter/flutter_rokid/.ios/Flutter/flutter_export_environment.sh"
"$FLUTTER_ROOT"/packages/flutter_tools/bin/xcode_backend.sh build

其中 "$FLUTTER_ROOT" 是我们安装flutter 时候 设置的环境变量,只要找到你自己的安装目录即可,然后通过整个路径找到 xcode_backend.sh 文件

第二步:分析脚本运行逻辑

我们看下里面一句比较关键的一段代码:

xcode_backend.sh 代码片段

    local build_mode="$(echo "${FLUTTER_BUILD_MODE:-${CONFIGURATION}}" | tr "[:upper:]" "[:lower:]")"
  local artifact_variant="unknown"
  case "$build_mode" in
    *release*) build_mode="release"; artifact_variant="ios-release";;
    *profile*) build_mode="profile"; artifact_variant="ios-profile";;
    *debug*) build_mode="debug"; artifact_variant="ios";;
    *)
      EchoError "========================================================================"
      EchoError "ERROR: Unknown FLUTTER_BUILD_MODE: ${build_mode}."
      EchoError "Valid values are 'Debug', 'Profile', or 'Release' (case insensitive)."
      EchoError "This is controlled by the FLUTTER_BUILD_MODE environment variable."
      EchoError "If that is not set, the CONFIGURATION environment variable is used."
      EchoError ""
      EchoError "You can fix this by either adding an appropriately named build"
      EchoError "configuration, or adding an appropriate value for FLUTTER_BUILD_MODE to the"
      EchoError ".xcconfig file for the current build configuration (${CONFIGURATION})."
      EchoError "========================================================================"
      exit -1;;
  esac

上面脚本中我们找到以下关键两句:

    local build_mode="$(echo "${FLUTTER_BUILD_MODE:-${CONFIGURATION}}" | tr "[:upper:]" "[:lower:]")"
  local artifact_variant="unknown"
  case "$build_mode" in
    *release*) build_mode="release"; artifact_variant="ios-release";;

上面这句脚本的含义是:我们在打包时候,是使用Xcode中的"Configuration"配置的名字 需要包含:*release*,*debug*,*proflie*,字段即可, 比如: test_release 会自动打包出release模式,再比如,ent_Debug 会默认为debug 默认进行打包;

其实到这里为止我们已经知道问题的答案:  只要将 beta_enterprise 改成 beta_release_enterprise 即可

:-1: ERROR: Unknown FLUTTER_BUILD_MODE: beta_enterprise.

总结

碰到问题不要紧张,也不要临时解决问题,一定要把本质弄清楚,这样问题自然就会引刃而解,此问题虽然花费了我不少时间,但是收益还是比较大的。

Flutter 打包报错 : Unknown FLUTTER_BUILD_MODE: xxx的更多相关文章

  1. 解决xcode10打包报错:That command depends on command in Target ‘xxx’:scrpit phase"[CP] Copy Pods Resources"

    问题:使用xcode10打包报错,提示 error:Multiple commands produce ‘xxxx/xxx.app’ 1)Target ‘xx’ has create director ...

  2. springboot项目POM文件第一行报错 Unknown Error

    改成 war 不错了,但是打包麻烦 pom 文件报错 UnKnown Error第一次碰到这个问题,花了几个小时才解决,除了UnKnown 没有任何提示.网上搜的大部分情况都不是我遇到的. 还是没有解 ...

  3. scp使用加密算法报错unknown cipher type

    为了提高scp的传输速度指定了scp的加密算法为arcfour $ scp -c arcfour localFile userName@remoteIP:remoteFile 得到报错unknown ...

  4. webpack 打包报错:One CLI for webpack must be installed. These are recommended choices, delivered as separate packages

    webpack 打包报错: One CLI for webpack must be installed. These are recommended choices, delivered as sep ...

  5. 端口报错listen eaddrinuse:::xxx

    端口报错 listen eaddrinuse:::xxx 表示这个端口被占用 结束正在使用此端的程序即可.

  6. maven install 打包 报错 Cannot run program "gpg.exe": CreateProcess error

    打包报错, mvn install后加上参数-Dgpg.skip,例如:mvn install -Dgpg.skip   即可解决. 我们也可以去掉 这个 插件   <plugin>    ...

  7. EF5+MVC4系列(2) EF5报错 无法确定“XXX”关系的主体端。添加的多个实体可能主键相同

    情景:用户表和订单表是一对多的关系,即 一个 Userinfo  对应对应有 多个 Order表   如果我在EF中,先创建一个用户,然后创建3个订单,然后关联这1个用户和3个订单的关系,毫无问题. ...

  8. vue-cli 打包报错:Unexpected token: punc (()

    vue-cli 打包报错: ERROR in static/js/vendor.ed7d2353f79d28a69f3d.js from UglifyJs Unexpected token: punc ...

  9. [one day one question] webpack 打包报错 Cannot assign to read only property 'exports' of object '#<Object>'

    问题描述: webpack 打包报错 Cannot assign to read only property 'exports' of object '#<Object>',这怎么破? 解 ...

随机推荐

  1. 命令行启动tomcat

    windows下进入CMD启动.window+r打开命令窗口具体步骤:1:在命令行中输入Tomcat安装的磁盘:E:2:进入Tomcat的主安装目录:cd Tomcat3:进入bin文件夹:cd bi ...

  2. Codeforces 743C - Vladik and fractions (构造)

    Codeforces Round #384 (Div. 2) 题目链接:Vladik and fractions Vladik and Chloe decided to determine who o ...

  3. Java门面模式(或外观模式)

    门面模式(或外观模式)隐藏系统的复杂性,并为客户端提供一个客户端可以访问系统的接口. 这种类型的设计模式属于结构模式,因为此模式为现有系统添加了一个接口以隐藏其复杂性.门面模式涉及一个类,它提供客户端 ...

  4. P3410 /// 最大流最小割

    题目大意: https://www.luogu.org/problemnew/show/P3410 题解 https://www.cnblogs.com/2020pengxiyue/p/9463055 ...

  5. Ubuntu 常用软件记录【持续更新】

    主机之间通信 Shell 管理器: asbru-cm 文件传输工具: filezilla 虚拟化 Virtual box

  6. 2018-2-13-win10-edge扩展

    title author date CreateTime categories win10 edge扩展 lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17:23 ...

  7. 2019-5-16-WPF-光标初始化的时候-temp-文件夹满了无法创建

    title author date CreateTime categories WPF 光标初始化的时候 temp 文件夹满了无法创建 lindexi 2019-05-16 19:16:27 +080 ...

  8. php导出csv并保存在服务器,返回csv的文件路径

    <?php namespace app\common\controller; use think\Controller; use think\Db; class Csv extends Cont ...

  9. python_django__验证码

    验证码:在用户注册/登陆时使用,为了防止暴力请求,减轻服务器压力,也是防止csrf的一种方式. 运行环境:python django 对应template模块htm函数: 登陆页面: <!DOC ...

  10. element-UI 点击一行,背景色变化

    代码: @row-click="rowClick" 当某一行被点击时会触发该事件 :row-class-name="tableRowClassName"  可以 ...