美文网首页
Flutter (一) 环境搭建

Flutter (一) 环境搭建

作者: 算命的李老师 | 来源:发表于2019-01-23 17:09 被阅读0次

参考资料

官网 https://flutterchina.club/setup-macos/
https://flutterchina.club/setup-macos/#平台设置

去官网按步操作

//镜像
命令行 export PUB_HOSTED_URL=https://pub.flutter-io.cn
命令行 export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
命令行 git clone -b master https://github.com/flutter/flutter.git

//设置默认flutter命令路径
命令行 export PATH='PWD'/flutter/bin:$PATH
命令行 flutter doctor

现在的环境变量只能在当前目录下flutter命令有效
如果想全局任意一个位置都有效,需要创建.bash_profile文件

在个人home目录下 比如我的目录 bogon:~ liguang$
输入touch .bash_profile
输入open .bash_profile
在文件内写入
export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn export PATH_TO_FLUTTER_GIT_DIRECTORY=/Users/liguang/flutter export PATH=${PATH}:${PATH_TO_FLUTTER_GIT_DIRECTORY}/bin
这里export PATH后跟随flutter sdk下载的目录
保存文件
命令行执行source ~/.bash_profile

环境变量配置完
命令行 flutter doctor
报错信息

[!] iOS toolchain - develop for iOS devices (Xcode 9.4.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**
 **✗ Brew can be used to install tools for iOS device development.**
 **Download brew at https://brew.sh/.**
[!] Android Studio (not installed)
[!] VS Code (version 1.27.2)
 **✗ Flutter extension not installed**; **install from**
[**https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter**](https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter)

需要分别安装

brew install --HEAD libimobiledevice
brew install ideviceinstaller

*****(如果没有brew命令 则安装brew)*****

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

然后根据报错信息分别安装提示的命令
✗ 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

完成上述后执行flutter doctor或在flutter/bin目录下执行./flutter doctor

发现还有报错

[!] iOS toolchain - develop for iOS devices

 **✗ 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**

出现如上错误是因为我安装Xcode之后没有把应用添加到应用程序目录下面:
这里把Xcode添加进去,在执行命令就好了。
命令行执行
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Password:

再次调用flutter doctor 发现没有报错

flutter help 在提示符下查看可用的工具

此时就已经配置完所有的信息
下一步就开始创建第一个Flutter APP
任意门
我的第一个hello word

相关文章

网友评论

      本文标题:Flutter (一) 环境搭建

      本文链接:https://www.haomeiwen.com/subject/yplsjqtx.html