用pod集成Flutter
打开xcode新建iOS工程,然后关闭xcode
在iOS工程根目录执行
1 | pod init |
以后用xcworkspace打开工程,不要用xcodeproj了
在 Podfile
中添加下面代码
1 | #这个路径指向flutter工程路径 |
在target节点下添加
1 | install_all_flutter_pods(flutter_application_path) |
目前iOS集成Flutter已经完成,寥寥数行代码而已.
在 iOS中把Flutter工程的代码Run起来
AppDelegate.h 继承FlutterAppDelegate,增加属性FlutterEngine
1 | #import <UIKit/UIKit.h> |
AppDelegate.m 重写didFinishLaunchingWithOptions方法
1 |
|
在ViewController.m的viewDidLoad方法新增代码
导包
1 | @import Flutter; |
1 |
|
新增方法
1 | - (void)showFlutter { |
运行即可