export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
cd ~/development
unzip ~/Downloads/flutter_macos_v0.5.1-beta.zip
export PATH=`pwd`/flutter/bin:$PATH
此時你會發現,你打開一個新的命令行窗口是,運行flutter doctor,會報flutter不存在的錯誤,是由於環境變量還沒全局生效android
錯誤詳情git
Android toolchain - develop for Android devices (Android SDK version 30.0.2) ✗ Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses [✗] Xcode - develop for iOS and macOS ✗ Xcode installation is incomplete; a full installation is necessary for iOS development. Download at: https://developer.apple.com/xcode/download/ Or install Xcode via the App Store. Once installed, run: sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch ✗ CocoaPods not installed. CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/platform-plugins To install: sudo gem install cocoapods [!] Android Studio (version 4.1) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. [!] VS Code (version 1.52.0) ✗ Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [!] Connected device ! No devices available
上面的錯誤信息是告訴你東西未安裝完,好比xcode,Android Studio,Android Studio的dart、fultter插件,CocoaPods,VS Code的flutter插件未安裝github
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer sudo xcodebuild -runFirstLaunch sudo gem install cocoapods
// 注意AndroidStudio版本號 ln -s ~/Library/Application\ Support/Google/AndroidStudio4.1/plugins ~/Library/Application\ Support/AndroidStudio4.1
echo $PATH // 能夠看到flutter的路徑爲 /Users/name/development/flutter/bin:
open ~/.bash_profile
vim ~/.bash_profile
// 建立bash_profile文件 touch .bash_profile
// 添加國內鏡像 export PUB_HOSTED_URL="https://pub.flutter-io.cn" export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn" // 添加安裝路徑,上面獲取到的 export PATH="/Users/name/development/flutter/bin:$PATH"
source ~/.bash_profile
最終的bash_profile文件macos
// .bash_profile # HomeBrew export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles export PATH="/usr/local/bin:$PATH" export PATH="/usr/local/sbin:$PATH" export PUB_HOSTED_URL="https://pub.flutter-io.cn" export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn" # name爲本身電腦的名稱 export PATH="/Users/name/development/flutter/bin:$PATH" source ~/.bashrc # HomeBrew END
github查看更多文章vim