日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

【原】MAC安裝Flutter

 路人甲Java 2020-09-22

系統(tǒng)環(huán)境要求

Flutter因為是新出的框架,所以對系統(tǒng)還是有一定的要求的。

  • MacOS(64-bit)
  • 磁盤空間:大于700M,如果算上Android Studio等編輯工具,盡量大于3G。
  • 命令號工具:bash、mkdir、rm、git、curl、unzip、which、brew 這些命令在都可以使用。

下載Flutter SDK包

官網(wǎng)鏈接:https:///setup-macos/

直接在 Get the Flutter SDK 中下載當(dāng)前最新的SDK

配置環(huán)境變量

壓縮包下載好以后,找個位置進(jìn)行解壓。這個位置很重要,因為下面配置環(huán)境變量的時候要用到。我配置到了當(dāng)前用戶目錄文件夾。

  1. 打開終端工具,使用vim進(jìn)行配置環(huán)境變量,命令如下:
vim ~/.bash_profile
  1. 在打開的文件中增加一行代碼
export PATH=/Users/用戶名/flutter/bin:$PATH

提示:這行命令你要根據(jù)你把壓縮包解壓的位置來進(jìn)行編寫,寫的是你的路徑,很有可能不跟文章一樣。

  1. 配置文件完成后,使用 source 命令重新加載一下,具體命令如下:
source ~/.bash_profile
  1. 使用命令檢查是否安裝成功,具體命令如下:
flutter -h

出現(xiàn)flutter可用命令提示后,表示安裝成功。

檢查開發(fā)環(huán)境

我們安裝好了Flutter,但是還不具備開發(fā)環(huán)境。開發(fā)還需要很多軟件和插件的支持,那到底需要哪些插件和軟件那?我們可以使用Flutter為我們提供的命令來進(jìn)行檢查:

flutter doctor

顯示結(jié)果:

[?] 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./studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https:///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./items?itemName=Dart-Code.flutter
[!] Connected device
    ! No devices available

注意:帶?的就必須安裝,帶??的就可以暫時忽略。
VS Code是我之前就安裝的,如果沒有安裝是不會出現(xiàn)下面這個帶?信息的

[!] VS Code (version 1.36.1)
   ? Flutter extension not installed; install from
     https://marketplace./items?itemName=Dart-Code.flutter

所以,這個暫時可以先忽略

解決帶?的問題

1、Android環(huán)境

1.1 安裝 Android Studio

打開 Android Studio, 打開 plugins ,安裝 flutter

完成后

[?] Android toolchain - develop for Android devices
    ? Unable to locate Android SDK.
      Install Android Studio from: https://developer./studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https:///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)

轉(zhuǎn)變?yōu)?/p>

[!] 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)
1.2 執(zhí)行 flutter doctor --android-licenses 同意相關(guān)協(xié)議

此處 N 多信息,都是相關(guān)協(xié)議文件,一路 y 即可。

.
.
.此處 N 多信息,都是相關(guān)協(xié)議文件,一路 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

轉(zhuǎn)變?yōu)?/p>

[?] Android toolchain - develop for Android devices (Android SDK version 28.0.3)

2、iOS環(huán)境

[!] 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環(huán)境時,就碰到一些坑

2.1 坑1:/usr/local is not writable.

看到這個提示,我們第一時間就是想著修改讀寫權(quán)限

當(dāng)你執(zhí)行sudo chown -R $(whoami) /usr/local進(jìn)行修改時,系統(tǒng)會有如下提示:

Operation not permitted

現(xiàn)在問題就卡住了,因為執(zhí)行brew update之類的命令,需要對/usr/local進(jìn)行寫入操作。但是操作用戶無法像對普通文件夾操作一樣,通過chown獲得write權(quán)限。由于/usr/local是系統(tǒng)文件夾,macOS限制了對其的操作權(quán)限。

蘋果從 OS X El Capitan 10.11 系統(tǒng)開始使用了 Rootless 機(jī)制,可以將該機(jī)制理解為一個更高等級的系統(tǒng)的內(nèi)核保護(hù)措施,系統(tǒng)默認(rèn)將會鎖定 /system、/sbin、/usr 這三個目錄。

在終端輸入

csrutil status

收到系統(tǒng)提示

System Integrity Protection status:enabled

說明rootless默認(rèn)打開,此時無法通過sudo命令,對/system、/sbin、/usr 這三個目錄進(jìn)行修改。

打開、關(guān)閉Rootless機(jī)制
  • 重啟Mac
  • 開機(jī)時后按下 Command+R,進(jìn)入恢復(fù)模式。
  • 在上面的菜單實用工具中找到并打開 Terminal
  • 輸入如下命令:
csrutil disable

此時rootless已經(jīng)關(guān)閉,退出恢復(fù)模式,正常進(jìn)入系統(tǒng)。在終端輸入

csrutil status

系統(tǒng)提示

System Integrity Protection status:disabled

rootless已關(guān)閉
可通過 sudo chown -R $(whoami) /usr/local 進(jìn)行權(quán)限修改
開啟rootless
在恢復(fù)模式的Terminal輸入如下命令:

csrutil enable

建議修改完成之后,為了系統(tǒng)安全,將rootless重新開啟。

2.2 坑2:缺少 autoconf、automakelibtool

本以為修改文件權(quán)限后就會一帆風(fēng)順,可惜天不遂人愿??创笈5牟タ投际且淮芜^,到自己這里就問題比較多。

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多