flutter加入到现有iOS项目

本文介绍了如何创建Flutter模块并将其整合到iOS项目中,包括将Fluttermodule添加到项目结构、修改Podfile以及执行podinstall命令。在执行过程中遇到的问题是CocoaPods找不到兼容的版本,原因是Podfile中的最低目标版本设置过低。通过将最低部署目标版本提升到9.0解决了此问题。
摘要由CSDN通过智能技术生成

1、创建 Flutter module

在桌面创建project目录

cd /Users/imac/Desktop/project
flutter create --template module my_flutter

2、将iOS项目(CureFunNew)放入my_flutter同一级目录

iOS项目(MyApp)放入后project目录结构

/Users/imac/Desktop/project/
├── my_flutter/
│   └── .ios/
│       └── Flutter/
│         └── podhelper.rb
└── CureFunNew/
    └── Podfile

3、给iOS项目中Podfile文件添加命令

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

install_all_flutter_pods(flutter_application_path)

加入命令后样子
在这里插入图片描述

4、执行pod install命令

pod install

执行成功效果
在这里插入图片描述

这里第一次运行遇见问题

[!] CocoaPods could not find compatible versions for pod "my_flutter":
  In Podfile:
    my_flutter (from `../my_flutter/.ios/Flutter`)

Specs satisfying the `my_flutter (from `../my_flutter/.ios/Flutter`)` dependency were found, but they required a higher minimum deployment target.

原因:Podfile中需要将最低目标版本设置为9.0

参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值