flutter ios打包_Flutter 将 Flutter 集成到现有项目(iOS Framework篇)

本文详细介绍了如何将Flutter集成到现有的iOS项目中,通过Flutter Module创建、打包,利用cocoapods和git管理,以及编写脚本自动化处理。文章遵循cai Jinglong大佬的文章,讨论了在过程中遇到的问题和解决方案,最终实现Flutter与iOS原生项目的无缝结合。
摘要由CSDN通过智能技术生成

本篇文章大幅参考了 caijinglong 大佬的总结文章: 把flutter作为framework添加到已存在的iOS中[1]

用 Flutter 来开发,从来都不可能是新开的一个纯 Flutter 项目,很大一部分都是 老项目接入 Flutter 来混编。

在 Flutter 官网 - Adding to an iOS app[2] 这里,官方也给出了一些将 Flutter 集成进入现有 iOS 项目的方法。但是,这些都多多少少的不符合我们的需求。

1. 从 Flutter Module 说起

想要把 Flutter 集成进现有 iOS 项目,我们就必须使用 Flutter Module

那就先用命令创建一个 Flutter Module:flutter create --template module flutter_test_module

49b0b5a11c460fc091d9a6205e5036d1.png

Flutter APP 和 Flutter Module 的不同之处在于 pubspec.yaml 最后一段:

# This section identifies your Flutter project as a module meant for# embedding in a native host app.  These identifiers should _not_ ordinarily# be changed after generation - they are used to ensure that the tooling can# maintain consistency when adding or modifying assets and plugins.# They also do not have any bearing on your native host application's# identifiers, which may be completely independent or the same as these.module:androidX: trueandroidPackage: com.example.flutter_test_moduleiosBundleIdentifier: com.example.flutterTestModule

这一段代码,把该 Flutter 项目标注为一个 module,用于嵌入到原生 app 里。

这里面设置了是否使用 androidx,Android 和 iOS

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值