環(huán)境:Flutter 1.9.1 fix6
1.The application's Info.plist does not contain CFBundleVersion.
默認(rèn)生成的Flutter module里面沒有bundle version及 build號(hào)榆俺, 填寫上即可.
2.為了方便大部分測(cè)試可能是在模擬器上進(jìn)行的,這樣首先避免了設(shè)備添加證書的限制蔫耽。
直到發(fā)現(xiàn)了一個(gè)問題卦洽,這個(gè)問題只在模擬器上出現(xiàn)火架,真機(jī)上正常:切換engin 的viewcontroller。
在iOS模擬器下钠糊,第二次使用engin 創(chuàng)建FlutterViewContainer時(shí)杉女, initWithEngine: 會(huì)crash贰剥,報(bào)錯(cuò)如下
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
這個(gè)錯(cuò)誤是由于僵尸指針導(dǎo)致倾剿。打開Zombie 指針調(diào)試后 可以看到控制臺(tái)打印如下錯(cuò)誤
[FlutterView setAccessibilityElements:]: message sent to deallocated instance 0x7ff4b30a6dc0
使用Instruments Zombie 工具調(diào)試具體信息如下。
最終定位到源碼蚌成,是engin下的setViewController:方法導(dǎo)致
self.iosPlatformView->SetOwnerViewController(_viewController);
"flutter::PlatformViewIOS::SetOwnerViewController(fml::WeakPtr<FlutterViewController>)+0x21"
相關(guān)engin源碼
https://github.com/flutter/engine/blob/master/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
這個(gè)問題在真機(jī)上不會(huì)出現(xiàn)前痘,具體原因未進(jìn)行深入排查。如果不改源碼自己維護(hù)engin的話担忧,只能真機(jī)測(cè)試了芹缔。
之后改為了真機(jī)測(cè)試,也遇到了一些配置問題瓶盛。
3.flutter module中如過不使用第三方plugin或者使用純dart package可能不會(huì)出現(xiàn)異常最欠,引用三方plugin時(shí)報(bào)如下錯(cuò)誤
Could not find or use auto-linked framework 'Flutter'
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FlutterError", referenced from:
objc-class-ref in BatteryPlugin.o
"_OBJC_CLASS_$_FlutterMethodChannel", referenced from:
objc-class-ref in BatteryPlugin.o
"_OBJC_CLASS_$_FlutterEventChannel", referenced from:
objc-class-ref in BatteryPlugin.o
"_FlutterMethodNotImplemented", referenced from:
-[FLTBatteryPlugin handleMethodCall:result:] in BatteryPlugin.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解決方法:
https://github.com/flutter/flutter/issues/17749
you have to have to set ONLY_ACTIVE_ARCH = YES for debug builds. Write this to you podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
config.build_settings['SWIFT_VERSION'] = '4.2'
config.build_settings['SUPPORTED_PLATFORMS'] = 'iphoneos iphonesimulator'
if config.name == "Debug" || config.name == "Debug-alpha" || config.name == "Debug-live" ||
config.name == "Debug-development"
config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
else
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
end
將以上添加到podfile中示罗。
4.Flutter.framework: Permission denied
Command PhaseScriptExecution failed with a nonzero exit code
解決:
https://github.com/flutter/flutter/issues/40146
packages/flutter_tools/bin/xcode_backend.sh
中 144行 將
RunCommand find "${derived_dir}/engine/Flutter.framework" -type f -exec chmod a-w "{}" \;
替換為
RunCommand find "${derived_dir}/engine/Flutter.framework" -type f -iname '.h' -exec chmod a-w "{}" \;
這個(gè)問題在1.9.1 fix6版本之前出現(xiàn),升級(jí)到1.12版本已經(jīng)修復(fù)這個(gè)問題
芝硬。