2、创建Xcode工程,并使用cocopods管理工程依赖;
//配置Podfile文件
#配置flutter模块路径
flutter_application_path = '../mudule_demo'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
target 'ios_flutter' do
use_frameworks!
#指定需要安装的flutter模块
install_all_flutter_pods(flutter_application_path)
end
4、原始层代码
import UIKit
import Flutter
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.view.backgroundColor = UIColor.yellow
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let flutterViewController = FlutterViewController(project: nil, nibName: nil, bundle: nil)
present(flutterViewController, animated: true, completion: nil)
}
}
5、OK,大功告成
成功.gif
网友评论