原生混编flutter

2023-04-05  本文已影响0人  无聊怎么聊_3151

cd 到flutter_module根目录

flutter build ios-framework --cocoapods --output=some/path/MyApp/Flutter/
WeChat5acd77e18cac421b3d8e6f078f2d379e.png

在pod中添加

pod 'Flutter', :podspec => 'some/path/MyApp/Flutter/[build mode]/Flutter.podspec'

之后再把xcframework拖入到项目中

这里待确定,不引用也不会有问题

//pubspec文件引入flutter_boost,我这里采用本地引入方式

flutter_boost:
    path: flutter_boost-3.0-null-safety-release.2.1

4.podfile文件添加

flutter_application_path = './flutter_module'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

target 'NaviteMixinFlutterDemo' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
  install_all_flutter_pods(flutter_application_path)
  # Pods for NaviteMixinFlutterDemo

end

  1. pod install 报错
    [!] Invalid Podfile file: Missing flutter_post_install(installer) in Podfile post_install block.

podfile文件添加

target 'myapp' do
// 用的各sdk
end
// 新增的配置
post_install do |installer|
  flutter_post_install(installer) if defined?(flutter_post_install)
end

1.在原生的项目同级目录中添加flutter_moudle.
2.app下的build.gradle文件中添加以下配置

compileOptions {
  sourceCompatibility 1.8
  targetCompatibility 1.8
}

3.在项目根目录下的setting.gradle文件中配置:

my_flutter为创建的flutter包明进行替换

include ':app'
// 加入下面配置
setBinding(new Binding([gradle: this]))
evaluate(new File(
        settingsDir.parentFile,
        'my_flutter/.android/include_flutter.groovy'
)) 

https://www.imgeek.net/article/825361249

-- 安卓的介入
https://www.codenong.com/jsd6d7f92952b3/

三种原生和flutter交互方式
https://blog.csdn.net/china_2014/article/details/111992010

https://www.jianshu.com/p/086d0ad44261

上一篇下一篇

猜你喜欢

热点阅读