方式一:需要xcode 、cocopad 、flutter
同级目录下:
iOS项目:MyApp 子目录 Podfile文件
flutter模块:flutter create --template module my_flutter
Podfile文件
platform:ios,'11.0'
flutter_application_path = '../my_flutter'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
post_install do |installer|
flutter_post_install(installer) if defined?(flutter_post_install)
end
target 'MyApp' do
install_all_flutter_pods(flutter_application_path)
end
在flutter module下执行flutter run,可运行demo
在 Xcode项目下执行 pod install,效果如下
iOS代码启动flutter页面:
swift代码
import UIKit
import FlutterPluginRegistrant
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
// lazy var flutterEngine = FlutterEngine(name: "my flutter engine")
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// flutterEngine.ru