iOS混編flutter填坑記

之前寫過(guò)一點(diǎn)點(diǎn)純flutter的項(xiàng)目,最近比較好奇原生跟flutter混編,于是按照官方文檔進(jìn)行配置集成flutter到現(xiàn)有工程,集成后pod install報(bào)錯(cuò),podfile中改為如下配置安裝成功

target 'flutter-test' do
end
flutter_application_path = '../my_flutter'
eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)

原生項(xiàng)目中跳轉(zhuǎn)flutter頁(yè)面代碼如下

- (IBAction)showFlutterOnClick:(UIButton *)sender {
    UIViewController *rootViewController = [[FlutterViewController alloc] initWithProject:nil nibName:nil bundle:nil];
    [self.navigationController pushViewController:rootViewController animated:YES];
}

點(diǎn)擊跳轉(zhuǎn)后可以跳轉(zhuǎn)但是報(bào)錯(cuò)如下

2020-05-09 15:18:39.443794+0800 flutter-test[14940:251135] Failed to find assets path for "Frameworks/App.framework/flutter_assets"
2020-05-09 15:18:39.510195+0800 flutter-test[14940:251300] [VERBOSE-2:engine.cc(118)] Engine run configuration was invalid.
2020-05-09 15:18:39.510379+0800 flutter-test[14940:251300] [VERBOSE-2:FlutterEngine.mm(308)] Could not launch engine with configuration.
2020-05-09 15:18:39.577726+0800 flutter-test[14940:251307] flutter: Observatory listening on http://127.0.0.1:61474/1vf_vYKqgAI=/

百度后,應(yīng)該增加如下腳本,具體配置參考Xcode 11.4 Support

/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" thin

重新編譯,點(diǎn)擊跳轉(zhuǎn)后正常顯示flutter頁(yè)面

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容