Android Studio创建Flutter模块
首先通过Android Studio 创建一个flutter module项目,注意用小写和下划线命名
将已有的原生项目拷贝到和flutter项目放到一个目录下
cocopods 引入Flutter模块
编辑podflile 如下:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
flutter_application_path = '../flutter_module/'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'NativeDemo' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for NativeDemo
#指定需要安装的flutter模块
install_all_flutter_pods(flutter_application_path)
end
pod install
添加脚本
添加Flutter目录宏
添加shell脚本
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
原生模块引入flutter
导入#import <Flutter/Flutter.h>
头文件
self.window.rootViewController = [[FlutterViewController alloc] init];
[self.window makeKeyAndVisible];
运行项目