flutter因为是新出的框架,所以对系统还是有一定的要求的。
官网链接:
直接在 get the flutter sdk 中下载当前最新的sdk
压缩包下载好以后,找个位置进行解压。这个位置很重要,因为下面配置环境变量的时候要用到。我配置到了当前用户目录文件夹。
vim ~/.bash_profile
export path=/users/用户名/flutter/bin:$path
提示:这行命令你要根据你把压缩包解压的位置来进行编写,写的是你的路径,很有可能不跟文章一样。
source
命令重新加载一下,具体命令如下:source ~/.bash_profile
flutter -h
出现flutter可用命令提示后,表示安装成功。
我们安装好了flutter,但是还不具备开发环境。开发还需要很多软件和插件的支持,那到底需要哪些插件和软件那?我们可以使用flutter为我们提供的命令来进行检查:
flutter doctor
显示结果:
[✓] flutter (channel stable, v1.2.1, on mac os x 10.13.6 17g4015, locale zh-hans-cn) [✗] android toolchain - develop for android devices ✗ unable to locate android sdk. install android studio from: https://developer.android.com/studio/ on first launch it will assist you in installing the android sdk components. (or visit https://flutter.io/setup/#android-setup for detailed instructions). if android sdk has been installed to a custom location, set android_home to that location. you may also want to add it to your path environment variable. [!] ios toolchain - develop for ios devices (xcode 10.2.1) ✗ libimobiledevice and ideviceinstaller are not installed. to install with brew, run: brew update brew install --head usbmuxd brew link usbmuxd brew install --head libimobiledevice brew install ideviceinstaller ✗ ios-deploy not installed. to install: brew install ios-deploy [!] android studio (not installed) [!] vs code (version 1.36.1) ✗ flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemname=dart-code.flutter [!] connected device ! no devices available
注意:带❌的就必须安装,带❗️的就可以暂时忽略。
vs code是我之前就安装的,如果没有安装是不会出现下面这个带❌信息的[!] vs code (version 1.36.1) ✗ flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemname=dart-code.flutter所以,这个暂时可以先忽略
android studio
打开 android studio
, 打开 plugins
,安装 flutter
完成后
[✗] android toolchain - develop for android devices ✗ unable to locate android sdk. install android studio from: https://developer.android.com/studio/ on first launch it will assist you in installing the android sdk components. (or visit https://flutter.io/setup/#android-setup for detailed instructions). if android sdk has been installed to a custom location, set android_home to that location. you may also want to add it to your path environment variable. . . . [!] android studio (not installed)
转变为
[!] android toolchain - develop for android devices (android sdk version 28.0.3) ✗ android licenses not accepted. to resolve this, run: flutter doctor --android-licenses . . . [✓] android studio (version 3.4)
flutter doctor --android-licenses
同意相关协议此处 n 多信息,都是相关协议文件,一路 y 即可。
. . .此处 n 多信息,都是相关协议文件,一路 y 即可。 . . --------------------------------------- accept? (y/n): y all sdk package licenses accepted
完成后
[!] android toolchain - develop for android devices (android sdk version 28.0.3) ✗ android licenses not accepted. to resolve this, run: flutter doctor --android-licenses
转变为
[✓] android toolchain - develop for android devices (android sdk version 28.0.3)
[!] ios toolchain - develop for ios devices (xcode 10.2.1) ✗ libimobiledevice and ideviceinstaller are not installed. to install with brew, run: brew update brew install --head usbmuxd brew link usbmuxd brew install --head libimobiledevice brew install ideviceinstaller ✗ ios-deploy not installed. to install: brew install ios-deploy
在安装ios环境时,就碰到一些坑
/usr/local is not writable.
看到这个提示,我们第一时间就是想着修改读写权限
当你执行sudo chown -r $(whoami) /usr/local
进行修改时,系统会有如下提示:
operation not permitted
现在问题就卡住了,因为执行brew update之类的命令,需要对/usr/local进行写入操作。但是操作用户无法像对普通文件夹操作一样,通过chown获得write权限。由于/usr/local是系统文件夹,macos限制了对其的操作权限。
苹果从 os x el capitan 10.11 系统开始使用了
rootless
机制,可以将该机制理解为一个更高等级的系统的内核保护措施,系统默认将会锁定/system
、/sbin
、/usr
这三个目录。
在终端输入
csrutil status
收到系统提示
system integrity protection status:enabled
说明rootless
默认打开,此时无法通过sudo命令,对/system
、/sbin
、/usr
这三个目录进行修改。
打开、关闭rootless机制
- 重启mac
- 开机时后按下
command+r
,进入恢复模式。- 在上面的菜单实用工具中找到并打开
terminal
- 输入如下命令:
csrutil disable此时
rootless
已经关闭,退出恢复模式,正常进入系统。在终端输入csrutil status系统提示
system integrity protection status:disabledrootless已关闭
可通过sudo chown -r $(whoami) /usr/local
进行权限修改
开启rootless
在恢复模式的terminal输入如下命令:csrutil enable建议修改完成之后,为了系统安全,将rootless重新开启。
autoconf
、automake
和libtool
本以为修改文件权限后就会一帆风顺,可惜天不遂人愿。看大牛的播客都是一次过,到自己这里就问题比较多。
如对本文有疑问, 点击进行留言回复!!
M - Jamie‘s Contact Groups POJ - 2289(二分 + 多重匹配)
H - Antenna Placement POJ - 3020(最小边覆盖)
Unity组件【Camera && Flare Layer】
K - Treasure Exploration POJ - 2594
网友评论