环境: macOS10.15.1 CocoaPods1.84 Xcode11.2.1 Flutter 1.9.1+hotfix.6
该演示需要flutter项目和iOS项目位于同一级目录,如下FlutterModuleIntoiOS
和flutter_module_smples
位于同一级目录下
├── FlutterModuleIntoiOS
│ ├── FlutterModuleIntoiOS
│ ├── FlutterModuleIntoiOS.xcodeproj
│ ├── FlutterModuleIntoiOS.xcworkspace
└── flutter_module_smples
├── README.md
├── build
├── flutter_module_smples.iml
├── flutter_module_smples_android.iml
├── lib
├── pubspec.lock
├── pubspec.yaml
└── test
通过CocoaPods嵌入Flutter SDK
- 在需要的引入的iOS代码创建一个
Podfile
文件(已创建直接看第二步)
pod init
- 在Podefile添加以下内容
platform :ios, '9.0'
flutter_application_path = '../flutter_module_smples'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'FlutterModuleIntoiOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
install_all_flutter_pods(flutter_application_path)
end
-
flutter_module_smples
这个是flutter项目的所在的文件名 -
FlutterModuleIntoiOS
iOS项目的Traget name
- 安装flutter moudle
pod install
如果出现这样,引入flutter成功