Flutter安装
1、下载flutter-sdk
下载地址:https://docs.flutter.dev/get-started/install/macos#
2、配置环境变量
vim ~/.bash_profile
点击i输入:
export PATH=/Users/用户名/Documents/flutter/bin:$PATH
export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub
export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter
是修改的环境变量生效
source ~/.bash_profile
然后运行
flutter doctor
出现
╔════════════════════════════════════════════════════════════════════════════╗
║ Welcome to Flutter! - https://flutter.dev ║
║ ║
║ The Flutter tool uses Google Analytics to anonymously report feature usage ║
║ statistics and basic crash reports. This data is used to help improve ║
║ Flutter tools over time. ║
║ ║
║ Flutter tool analytics are not sent on the very first run. To disable ║
║ reporting, type 'flutter config --no-analytics'. To display the current ║
║ setting, type 'flutter config'. If you opt out of analytics, an opt-out ║
║ event will be sent, and then no further information will be sent by the ║
║ Flutter tool. ║
║ ║
║ By downloading the Flutter SDK, you agree to the Google Terms of Service. ║
║ Note: The Google Privacy Policy describes how data is handled in this ║
║ service. ║
║ ║
║ Moreover, Flutter includes the Dart SDK, which may send usage metrics and ║
║ crash reports to Google. ║
║ ║
║ Read about data we send with crash reports: ║
║ https://flutter.dev/docs/reference/crash-reporting ║
║ ║
║ See Google's privacy policy: ║
║ https://policies.google.com/privacy ║
╚════════════════════════════════════════════════════════════════════════════╝
Flutter assets will be downloaded from
https://mirrors.tuna.tsinghua.edu.cn/flutter. Make sure you trust this source!
Running "flutter pub get" in flutter_tools... 21.5s
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.2, on macOS 11.6.4 20G417 darwin-x64, locale zh-Hans-CN)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed
instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
✗ 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 see https://guides.cocoapods.org/using/getting-started.html#installation for
instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] Connected device (2 available)
! Error: lei is busy: Fetching debug symbols for lei. Xcode will continue when lei is finished.
(code -10)
[!] HTTP Host Availability
✗ HTTP host https://maven.google.com/ is not reachable. Reason: An error occurred while checking
the HTTP host: Operation timed out
说明安装成功 ,然后需要配置全部生效和配置开发工具
设置iOS模拟器
输入
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer //然后需要输入密码
sudo xcodebuild -license //输入之后一直按空格,最后需要输入agree
open -a Simulator
brew update
brew install --HEAD libimobiledevice
brew install ideviceinstaller ios-deploy cocoapods
pod setup
具体有什么疑问可以参考flutter中文网
永久解决
复制.bash_profile的内容
vim ~/.zshrc
然后把复制的内容粘贴在执行
source ~/.zshrc
flutter doctor
Flutter 升级SDK
未下载待更新的sdk版本
1、cd进入到Flutter SDK目录下
2、运行flutter upgrade
3、运行flutter doctor 查看是否已升级成功
已下载待更新的sdk版本
1、cd进入到Flutter SDK目录下
2、运行flutter upgrade 例如:flutter upgrade v3.3.3
3、运行flutter doctor 查看是否已升级成功
网友评论