赞
踩
1.创建一个新的iOS工程,并添加cocopod
2.在iOS工程中输入命令
$ flutter create -t module android_flutter_module
该命令将会创建一个module类型的flutter工程
3.修改Podfile文件
- # Uncomment the next line to define a global platform for your project
- platform :ios, '8.0'
-
- target 'FOne' do
- # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
- # use_frameworks!
- target 'FOneTests' do
- inherit! :search_paths
- # Pods for testing
- end
-
- target 'FOneUITests' do
- inherit! :search_paths
- # Pods for testing
- end
-
-
- end
- flutter_application_path = '../android_flutter_module'
- eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
只需要添加
flutter_application_path = '../android_flutter_module'
eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
这两行就行了,这里应该注意flutter_application_path路径是第二步创建的module绝对路径,因为在Podfile文件的上层文件夹,这里只需要‘’ ../ ‘’就行,也推荐把module创建在上层文件夹中
4.修改Xocde配置
4.1 修改Xocde Build Setting中Enable Bitcode为NO
4.2 添加Run Script
- "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
- "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
注意:如果是Xcode10以上版本需要删除 project.pbxproj
文件中的inputFileListPaths
和outputFileListPaths
。
5.pod install
出现Development Pods文件夹就可以进行下一步(该文件夹下不一定有这么多子文件夹)
6.修改iOS工程中的AppDelegate.h文件和AppDelegate.m文件
7.测试
在ViewController中创建一个按钮点击
- - (void)handleButtonAction {
- FlutterViewController *flutterViewController = [[FlutterViewController alloc] init];
- flutterViewController.view.backgroundColor = [UIColor cyanColor];
- [flutterViewController setInitialRoute:@"route1"];
- [self presentViewController:flutterViewController animated:YES completion:nil];
- }
哒哒哒。。。。。。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。