美文网首页
【Flutter】和原生混合开发,通过cocoapods打包给原

【Flutter】和原生混合开发,通过cocoapods打包给原

作者: 西瓜吃了吗 | 来源:发表于2024-04-15 13:09 被阅读0次

上一篇文章是通过终端指令打包flutter为framework,这一篇我们使用cocoapods打包framework!
1.在终端进入Flutter项目里:cd xx/xx/xx/flutter_module

cd xx/xx/xx/flutter_module

2.在终端输入 flutter build ios-framwork --cocoapods --output=../flutter_app,构建混合工程,../flutter_app 为你想要的的混合过程路径。

flutter build ios-framwork --cocoapods --output=../flutter_app

3.构建完成后,flutter_app 下会同样也会有三个目录:Debug、Profile、release,没个目录下有两个framework:App.xcframework(提供Flutter项目开发的代码)、Flutter.podspec(Flutter 环境)。


图1.jpg

4.将App.xcframework、Flutter.podspec导入到原生工程文件目录里,在:Target ->General->Frameworks,libraries,and Embedded content 里添加App.xcframework

  1. pod init,在podflie 里输入 pod 'Flutter',:podspec => '../Flutter.podspec' (Flutter.podspec 路径):
platform :ios, '12.0'

target 'NativeDemo' do
  use_frameworks!
  pod 'Flutter',:podspec => '../Flutter.podspec'
  # Pods for NativeDemo

end

5.pod install
6.编译运行,就OK了,可以在原生项目里开发flutter了。

相关文章

网友评论

      本文标题:【Flutter】和原生混合开发,通过cocoapods打包给原

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