現(xiàn)象:項目中集成了flutter, 使用iOS14系統(tǒng)真機(jī)在斷開調(diào)試后,點擊App圖標(biāo)啟動閃退。
原因:deug模式下,flutter為了實現(xiàn)熱重載,默認(rèn)編譯方式為JIT。而iOS14系統(tǒng)對這種編譯模式做了限制,導(dǎo)致無法啟動。
解決方案:
1.更改XCode編譯模式:使用release模式編譯,這個時候flutter編譯方式為AOT,可正常啟動。
2.不更改XCode編譯模式:更改flutter編譯配置,強(qiáng)制設(shè)置為release。找到flutter安裝位置,依次打開flutter/packages/flutter_tools/bin/xcode_backend.sh
ParseFlutterBuildMode() {
# Use FLUTTER_BUILD_MODE if it's set, otherwise use the Xcode build configuration name
# This means that if someone wants to use an Xcode build config other than Debug/Profile/Release,
# they _must_ set FLUTTER_BUILD_MODE so we know what type of artifact to build.
local build_mode="$(echo "${FLUTTER_BUILD_MODE:-${CONFIGURATION}}" | tr "[:upper:]" "[:lower:]")"
case "$build_mode" in
*release*) build_mode="release";;
*profile*) build_mode="profile";;
*debug*) build_mode="debug";;
*)
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
echo "${build_mode}"
}
ParseFlutterBuildMode是flutter獲取編譯模式的函數(shù),如果沒有自主設(shè)置將和Xcode編譯模式保持一致,可以修改local build_mode="release"。強(qiáng)制flutter的編譯模式為release。
新增:flutter版本3.0.0在xcode_backend.drat中修改
————————————————
版權(quán)聲明:本文為CSDN博主「桃花仙丶」的原創(chuàng)文章,遵循CC 4.0 BY-SA版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/m0_38126868/article/details/110128841