之前写过一点点纯flutter的项目,最近比较好奇原生跟flutter混编,于是按照官方文档进行配置集成flutter到现有工程,集成后pod install报错,podfile中改为如下配置安装成功
target 'flutter-test' do
end
flutter_application_path = '../my_flutter'
eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
原生项目中跳转flutter页面代码如下
- (IBAction)showFlutterOnClick:(UIButton *)sender {
UIViewController *rootViewController = [[FlutterViewController alloc] initWithProject:nil nibName:nil bundle:nil];
[self.navigationController pushViewController:rootViewController animated:YES];
}
点击跳转后可以跳转但是报错如下
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=/
百度后,应该增加如下脚本,具体配置参考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
重新编译,点击跳转后正常显示flutter页面
网友评论