美文网首页
iOS混编flutter填坑记

iOS混编flutter填坑记

作者: multisim10 | 来源:发表于2020-05-09 15:22 被阅读0次

    之前写过一点点纯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页面

    相关文章

      网友评论

          本文标题:iOS混编flutter填坑记

          本文链接:https://www.haomeiwen.com/subject/rhuknhtx.html