首页 > 移动平台 > 详细

Flutter for iOS模拟器环境搭建

时间:2020-03-30 18:44:54      阅读:291      评论:0      收藏:0      [点我收藏+]

首先需要有Mac环境,请参考VMware 14安装OS X10.11
其次需要XCode开发环境,请参考虚拟机macOS Mojave10.14安装XCode10.1
最后参考官方文档:https://flutter.cn/docs/get-started/install/macos

将flutter_macos_v1.12.13+hotfix.8-stable.zip拷贝至Mac OS10.11虚拟机,XCode安装的是10.1,此时执行flutter doctor
技术分享图片

Flutter v1.12.13版本最低需要一个Xcode11.0.0版本!
经验证Flutter v1.9.1版本与Xcode10.1可以兼容。
更换版本后,执行flutter doctor,提示CocoaPods not installed!

安装CocoaPods
1.删除原来的ruby源:
gem sources --remove https://rubygems.org/ 
2.添加国内镜像:
gem sources -a https://gems.ruby-china.com/   #保证访问正常
3.更新gem
sudo gem update
4.安装cocoapods
sudo gem install cocoapods
5.pod安装
pod setup
技术分享图片

可以看到No devices available
打开Xcode自带的iOS虚拟机后(open -a Simulator或直接点击程序坞中的模拟器图标),即可识别Connected device
技术分享图片

iOS模拟器运行flutter example hello_word
$ cd ./flutter/examples/hello_world
技术分享图片

$ flutter run
Running "flutter pub get" in hello_world... 1.0s
Launching lib/main.dart on iPhone XR in debug mode...
Running Xcode build...

├─Assembling Flutter resources... 7.4s
└─Compiling, linking and signing... 58.9s
Xcode build done. 73.1s
Syncing files to device iPhone XR...
9,664ms (!)

?? To hot reload changes while running, press "r". To hot restart (and rebuild
state), press "R".
An Observatory debugger and profiler on iPhone XR is available at:
http://127.0.0.1:50297/sr6BSTwfCJ4=/
For a more detailed help message, press "h". To detach, press "d"; to quit,
press "q".
技术分享图片

 

技术分享图片

 

技术分享图片

如果要在iOS真机上运行,还需要以下配置:

$ brew install --HEAD libimobiledevice
$ brew install ideviceinstaller
$ brew install ios-deploy
$ brew install cocoapods
$ pod setup
$ pod --version
$ pod repo update --verbose
最后执行flutter doctor检查环境是否配置好!
由于我没有iphone真机,所以不再详细说明,请参考官方文档:https://flutter.cn/docs/get-started/install/macos

 

Flutter for iOS模拟器环境搭建

原文:https://www.cnblogs.com/MakeView660/p/12600212.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!