flutterFlutter知识库

Flutter module方式集成到iOS工程中

2020-03-08  本文已影响0人  godLoveYao

本篇讲述Flutter module如何集成、调试、打包发布三个问题

一、集成

Flutter module集成方式有三种:pod管理集成(简单快捷本篇是基于此)、手动通过flutter build ios-framework生成并管理framework、最后是flutter build ios-framework --cocoapods(需要flutter SDK v1.13.6及以上才支持);pod集成方式步骤如下:

target ‘hunHePrg’ do
  
  flutter_application_path = './my_flutter'
  load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
  install_all_flutter_pods(flutter_application_path)

    pod 'SVProgressHUD'
end

二、调试

这里使用的是vs code 编辑器,打开my_flutter代码

1,不需要断点,

image.png

2,断点调试

image.png

三、打包

遇到的问题

错误1

ERROR: Unknown FLUTTER_BUILD_MODE: dailybuild.

Valid values are 'Debug', 'Profile', or 'Release' (case insensitive).

This is controlled by the FLUTTER_BUILD_MODE environment variable.

If that is not set, the CONFIGURATION environment variable is used.



You can fix this by either adding an appropriately named build

configuration, or adding an appropriate value for FLUTTER_BUILD_MODE to the

.xcconfig file for the current build configuration (DailyBuild).

========================================================================

Command /bin/sh failed with exit code 255

解决方案

image.png
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;;

假如 FLUTTER_BUILD_MODE环境变量读取失败,那么可以将要编译的CONFIGURATION 设置成包含release、profile、debug字符样式,比如我这里的CONFIGURATION 是dailybuild 那就改成 dailybuild_release样式。

上一篇下一篇

猜你喜欢

热点阅读