cd MyApp/
- 执行如下指令,生成Podfile文件
pod init
- 默认创建的Podfile文件内容如下
Uncomment the next line to define a global platform for your project
platform :ios, ‘9.0’
target ‘MyApp’ do
Comment the next line if you don’t want to use dynamic frameworks
use_frameworks!
Pods for MyApp
target ‘MyAppTests’ do
inherit! :search_paths
Pods for testing
end
target ‘MyAppUITests’ do
Pods for testing
end
end
- 修改Podfile文件的内容(导入flutter模块)
Uncomment the next line to define a global platform for your project
platform :ios, ‘9.0’
flutter_application_path = ‘…/my_flutter’
load File.join(flutter_application_path, ‘.ios’, ‘Flutter’, ‘podhelper.rb’)
target ‘MyApp’ do
Comment the next line if you don’t want to use dynamic frameworks
use_frameworks!
install_all_flutter_pods(flutter_application_path)
Pods for MyApp
target ‘MyAppTests’ do
inherit! :search_paths
install_all_flutter_pods(flutter_application_path)
Pods for testing
end
target ‘MyAppUITests’ do
install_all_flutter_pods(flutter_application_path)
Pods for testing
end
end
说明:CocoaPods 相关请参考官网
1-platform:ios版本9.0
2-flutter_application_path = ‘…/my_flutter’:flutter模块的路径
- 执行
pod install
命令
六 打开混合后的项目空间(MyApp.xcworkspace)
- 关闭Xcode,找到Ios2Flutter/MyApp/MyApp.xcworkspace,用xcod打开
- 打开后的项目包含iOS原生项目(MyApp)和Flutter依赖Pods
⌘B
或者Product—>Build
编译项目,编译成功后Flutter已成功导入,可以在iOS中正常使用
7.1 IOS跳转Flutter界面
在Main.storyboard上添加一个按钮IOS跳转Flutter
7.2 ViewController中跳转Flutter方法
import UIKit
import Flutter
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func jumpFlutter(_ sender: Any)
{
let flutterViewController = FlutterViewController.init()
present(flutterViewController, animated: true, completion: nil)
总结
现在新技术层出不穷,如果每次出新的技术,我们都深入的研究的话,很容易分散精力。新的技术可能很久之后我们才会在工作中用得上,当学的新技术无法学以致用,很容易被我们遗忘,到最后真的需要使用的时候,又要从头来过(虽然上手会更快)。
我觉得身为技术人,针对新技术应该是持拥抱态度的,入了这一行你就应该知道这是一个活到老学到老的行业,所以面对新技术,不要抵触,拥抱变化就好了。
Flutter 明显是一种全新的技术,而对于这个新技术在发布之初,花一个月的时间学习它,成本确实过高。但是周末花一天时间体验一下它的开发流程,了解一下它的优缺点、能干什么或者不能干什么。这个时间,并不是我们不能接受的。
如果有时间,其实通读一遍 Flutter 的文档,是最全面的一次对 Flutter 的了解过程。但是如果我们只有 8 小时的时间,我希望能关注一些最值得关注的点。
(跨平台开发(Flutter)、java基础与原理,自定义view、NDK、架构设计、性能优化、完整商业项目开发等)
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
874067)]
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!