iOS 集成Flutter

2023-01-08  本文已影响0人  蜗牛锅

1、第一步:

在iOS项目的同级目录下创建flutter工程

flutter create -t module flutter_library


如图的项目位置.png

2、第二步:

cd flutter_library

flutter build ios --debug --no-codesign

flutter build ios --release --no-codesign

等待编译完成

3、第三步:

在iOS项目中添加

platform :ios,'9.0'

flutter_application_path ='../flutter_library/' #相对目录

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

target 'FlutteriOS' do

use_frameworks!

install_all_flutter_pods(flutter_application_path)

Pods for FlutteriOS

end

然后pod install
这时候基本完成了配置,具体就是iOS怎么调用flutter的项目

4、第四步:

import

@interface AppDelegate : FlutterAppDelegate <UIApplicationDelegate>

@property (nonatomic,strong) FlutterEngine *flutterEngine;

@end

2、

import<FlutterPluginRegistrant/GeneratedPluginRegistrant.h>// 如果你需要用到Flutter插件时

}

5、第五步:

FlutterViewController* flutterViewController = [[FlutterViewController alloc] initWithProject:nil nibName:nil bundle:nil];
flutterViewController.navigationItem.title=@"Flutter Demo";
 [self presentViewController:flutterViewController animated:YES completion:nil];
上一篇 下一篇

猜你喜欢

热点阅读