1、创建Flutter module
终端执行以下命令,需要在iOS项目同一级目录下
flutter create -t module my_flutter
2、Podfile文件
platform :ios, '10.0'
flutter_application_path = '../my_flutter'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'XXXXX' do
use_frameworks!
install_all_flutter_pods(flutter_application_path)
end
3、执行 pod install
4、AppDelegate文件
import Flutter
import FlutterPluginRegistrant
class AppDelegate: FlutterAppDelegate
{
//var window: UIWindow?
lazy var flutterEngine = FlutterEngine(name: "my flutter engine")
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
flutterEngine.run()
GeneratedPluginRegistrant.register(with: self.flutterEngine)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
5、iOS跳转到Flutter页面
let flutterEngine = (UIApplication.shared.delegate as! AppDelegate).flutterEngine
let vc = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
navigationController?.pushViewController(vc, animated: true)
网友评论