Flutter Modul集成到IOS项目中
官方网站资料:Flutter modul集成到现有IOS项目
中文官网资料:Flutter modul集成到现有IOS项目
Flutter UI组件可以逐渐地内嵌到你现有的IOS中,官方提供一下三种方法:
- Use the CocoaPods dependency manager and installed Flutter SDK. In this case, the flutter_module is compiled from the source each time the app is built. (Recommended.) (使用Cocoapods依赖管理器安装Flutter SDK,每次构建应用都会从源码中编译flutter_modul 官方推荐)
- Create frameworks for the Flutter engine, your compiled Dart code, and all Flutter plugins. Here, you manually embed the frameworks, and update your existing application’s build settings in Xcode. This can be useful for teams that don’t want to require every developer to have the Flutter SDK and Cocoapods installed locally.(创建一个框架,把 Flutter 引擎、已编译的 Dart 代码和所有 Flutter 插件都放进去 这种方式你可以手动嵌入这个框架,并在 Xcode 中更改现有的应用的构建设置。如果不想要求开发团队的每一位成员都在本地安装 Flutter SDK 和 Cocoapods,这种方式比较适用。)
- Create frameworks for your compiled Dart code, and all Flutter plugins. Use CocoaPods for the Flutter engine. With this option, embed the frameworks for your application and the plugins in Xcode, but distribute the Flutter engine as a CocoaPods podspec. This is similar to the second option, but it provides an alternative to distributing the large Flutter.xcframework.(为已编译的 Dart 代码和所有 Flutter 插件创建一个框架,对 Flutter 引擎使用 CocoaPods 来管理 这种方式是将应用内容和插件作为内嵌的框架,但将 Flutter 引擎作为 CocoaPods podspec 分发。这有点类似第二种方式,但是它为分发大型的 Flutter.xcframework 文件提供了替代方案。)
开发环境必须要满足Flutter对Mac OS系统的版本要求,并且已经安装Xcode, Flutter支持IOS11及以上。此外还需要1.10版本以上的Cocoapods。
1. 创建一个Flutter Modul
为了将Flutter集成到引用内,参考上面的任意方法创建一个Flutter Modul.执行命令行:flutter create --template module cocaopods_test(名称), 如果你是使用上面的第一种方法,来集成Flutter Modul,那么你应在与现有IOS应用工程父目录中创建这个Flutter Modul
在这个目录中,你可以像在其它 Flutter 项目中一样,执行 flutter 命令。比如 flutter run --debug 或者 flutter build ios。同样,你也可

本文详细介绍了如何将FlutterModul集成到iOS项目中,包括创建FlutterModul、使用Cocoapods管理依赖、直接在Xcode中集成framework以及处理本地网络权限。文中提到了Flutter的三种构建模式:debug、Release和Profile,以及在不同模式下的特点和使用场景。同时,强调了在集成过程中需要注意的配置问题,如平台版本兼容性和权限设置。
最低0.47元/天 解锁文章
6325

被折叠的 条评论
为什么被折叠?



