(ios,Android,Xcode,Android Studio,VScode,IDEA)

1)安装Flutter SDK

2)iOS 环境配置

3)Android Studio配置

4)VS code 配置

5)IntelliJ IDEA 配置 Flutter

正文

Flutter是谷歌的移动UI框架,可以快速在iOS和Android上构建高质量的原生用户界面。 Flutter可以与现有的代码一起工作。在全世界,Flutter正在被越来越多的开发者和组织使用,并且Flutter是完全免费、开源的。

这里我就详细介绍一下 Flutter 在mac 上的环境部署以及开发准备。Flutter 是为了跨平台而生的,所以为了验证在iOS和Android 的运行情况,必须先在mac 上配置好 iOS 的开发环境 Xcode 和 Android 的开发环境 Android Studio。这里我就不在展开写 Xcode 和 Android Studio 的安装配置过程了,这算是开发Flutter 的前提条件吧。另外,我个人更喜欢IntelliJ IDEA 的Flutter 开发环境,所以,也将IDEA 的配置Flutter方法放在最后。

所以本文流程就是先Flutter SDK
然后 Xcode 和 Android Studio
最后是IDE:VS code 和 IntelliJ IDEA

1)安装Flutter SDK

安装方法:
这里使用的是git安装

//1.终端中输入以下指令克隆项目
git clone -b beta https://github.com/flutter/flutter.git
//2. 导出到Flutter保存路径
export PATH=`pwd`/flutter/bin:$PATH

由于国内网络限制我们可以通过修改镜像地址来解决, 好在Google良心,专门给我们大陆提供了方案, 终端中一次输入以下命令即可解决。

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
git clone -b dev https://github.com/flutter/flutter.git
export PATH="$PWD/flutter/bin:$PATH"
cd ./flutter
flutter doctor

关于flutter doctor

flutter doctor 是 flutter 对mac本机的环境配置诊断脚本,脚本结果会直接放出 flutter 环境有哪些需要继续配置的。按照提示执行脚本即可。

下面是我的flutter 诊断结果

caobo:flutter caobo56$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v0.10.2, on Mac OS X 10.14 18A391, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
✗ libimobiledevice and ideviceinstaller are not installed. To install, run:
brew install --HEAD libimobiledevice
brew install ideviceinstaller
[✓] Android Studio (version 3.2)
[✓] VS Code (version 1.28.2)
[!] Connected device
! No devices available

2)iOS 环境配置

正常情况下,如果没有安装Xcode,一般会先让你安装Xcode,并且一般要求最新版,但我的已经装了,此步略

按照 flutter doctor 提示: iOS toolchain 配置有问题,并且给出了解决方案:

[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
✗ libimobiledevice and ideviceinstaller are not installed. To install, run:
brew install --HEAD libimobiledevice
brew install ideviceinstaller

这里需要说明的是,libimobiledevice 是调用iOS模拟器的一个第三方库,flutter 使用这个库调用iOS模拟器运行project,十分重要。

这里依次执行安装脚本即可。

    brew install --HEAD libimobiledevice
brew install ideviceinstaller

我在安装的过程中,libimobiledevice 的安装遇到了一个问题:

brew install --HEAD libimobiledevice

==> Cloning [https://git.libimobiledevice.org/libimobiledevice.git](https://git.libimobiledevice.org/libimobiledevice.git) Updating /Users/rjoiner/Library/Caches/Homebrew/libimobiledevice--git

==> Checking out branch master Already on 'master' Your branch is up to date with 'origin/master'. HEAD is now at b34e343 tools: Remove length check on device UDID arguments to support newer devices

==> ./autogen.sh Last 15 lines from /Users/rjoiner/Library/Logs/Homebrew/libimobiledevice/01.autogen.sh: checking dynamic linker characteristics... darwin16.7.0 dyld checking how to hardcode library paths into programs... immediate checking for pkg-config... /usr/local/opt/pkg-config/bin/pkg-config

checking pkg-config is at least version 0.9.0... yes checking for libusbmuxd >= 1.1.0... no configure: error: Package requirements (libusbmuxd >= 1.1.0) were not met:

Requested 'libusbmuxd >= 1.1.0' but version of libusbmuxd is 1.0.10

仔细看最后一行,我们会发现异常所在Requested 'libusbmuxd >= 1.1.0' but version of libusbmuxd is 1.0.10,很显然是由于系统要求的 libusbmuxd版本和所要安装的版本不一致。

经过一番搜索终于找到了问题所在:

A recent change to libimobiledevice bumped the constraint on libusbmuxd to >= version 1.1.0. The current usbmuxd homebrew package is version 1.0.10.
As a result, homebrew --HEAD installs of libimobiledevice no longer build without a --HEAD install of usbmuxd.
Until the usbmuxd homebrew formula is updated, a workaround is to install it at HEAD:

总之就是libimobiledevice更新了,我们可以通过下面的方式安装libimobiledevice:

brew update
brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd
brew link usbmuxd
brew install --HEAD libimobiledevice

其中,usbmuxd如果安装有问题,可以尝试直接 unlink/link usbmuxd,然后再执行 brew install --HEAD libimobiledevice 即可。我的就是这样解决了。

caobo:flutter caobo56$ brew install --HEAD libimobiledevice
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae. ==> Cloning https://git.libimobiledevice.org/libimobiledevice.git
Updating /Users/caobo/Library/Caches/Homebrew/libimobiledevice--git
==> Checking out branch master
Already on 'master'
Your branch is up to date with 'origin/master'.
HEAD is now at 92c5462 idevicebackup2: Fix scan_directory() for platforms not having d_type in struct dirent
==> ./autogen.sh
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/libimobiledevice/HEAD-92c5462_3 --without-cython -
==> make install

mac 上配置flutter开发环境的更多相关文章

  1. mac上配置php开发环境

    玉忠之前在我的mac上配置过,当时项目不能区分大小写,所以就没成功,我现在在他得基础上继续配置,希望成功. 教程:http://my.oschina.net/joanfen/blog/171109 以 ...

  2. (转)在mac上配置cocos2d-x开发环境

    转自:http://www.cnblogs.com/xiaodao/archive/2013/01/08/2850751.html 一.下载cocos2d-x最新安装包 在终端中cd到本地将要存放目录 ...

  3. mac上配置java开发环境

    项目在mac上跑起来的步骤: 1. 访问,https://brew.sh/  装上这个然后  brew install git  brew install maven, settings.xml需要放 ...

  4. Mac上配置Cocos2d-x开发环境(多平台:Android/iOS)

    下载以下资源: Cocos2d-x (http://www.cocos2d-x.org) Android NDK(http://developer.android.com/tools/sdk/ndk/ ...

  5. 在mac上配置cocos2d-x开发环境

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u012282115/article/details/24374539 一.首先下载cocos2d-x ...

  6. 安装与配置Flutter开发环境

    这篇博客我们介绍了Flutter,并且对比了H5,React Native,Flutter. 由于Flutter是跨平台的开发框架,开发一次可以同时运行在Android和iOS上面,所以我们开发时最好 ...

  7. 在 macOS 上搭建 Flutter 开发环境

    下载 Flutter SDK flutter官网下载:https://flutter.io/sdk-archive/#macos 若上述链接无法访问,可通过GitHub下载 https://githu ...

  8. 【Flutter 1-2】在 Windows 10下安装Flutter+Dart+Android Studio 配置Flutter开发环境

    在 Windows 10下安装Flutter+Dart+Android Studio 配置Flutter开发环境 文章首发地址 配置环境变量 由于部分网站被墙的原因,我们需要先配置Flutter国内镜 ...

  9. Mac OS 上配置java开发环境

    在开始本学期的java课程前,我需要先为自己的电脑配置好Java的开发环境.由于电脑是mac操作系统,所以教材上的教程对我并不管用,于是乎开始动手自己查阅网上资料来解决. 1.安装JDK 1.访问Or ...

随机推荐

  1. Logstash测试的时候,报Error occurred during initialization of VM,Could not reserve enough space for object heap

    今天配置Logstash的时候,启动输入logstash ‐e 'input { stdin { } } output { stdout {} }'就开始报错了,Error occurred duri ...

  2. Lambda表达式和方法引用

    1 , 为什么用lambda表达式 将重复固定的代码写法简单化 2   ,lambda表达式的实质 对函数式接口的实现(一个接口中只有一个抽象方法的接口被称为函数式接口) package com.mo ...

  3. 快速获取更丰富的Sitecore体验数据库

    无论您是否立即使用Sitecore的营销功能,我们强烈建议您执行这三项任务,以使您的数据收集更加丰富,并为您以后的决策留下良好的位置. Sitecore的体验数据库,即xDB,是Sitecore营销平 ...

  4. comment on exported function Perimeter should be of the form "Perimeter ..."go-lint

    这个提示是检查代码注释格式有问题 正确方式:

  5. C++删除排序数组中的重复项

    class Solution { public: int removeDuplicates(vector<int>& nums) { if (nums.empty()) { ; } ...

  6. Django ORM 数据库增删改查

    Django ORM 数据库增删改查 增 # 创建.增加数据(推荐) models.UserInfo.objects.create(username=') # 创建.增加数据 dic = {'} mo ...

  7. 可落地的DDD的(2)-为什么说MVC工程架构已经过时

    摘要 mvc是一种软件设计模式,最早由Trygve Reenskaug在1978年提出,他有效的解决了表示层,控制器层,逻辑层的代码混合在一起的问题,很好的做到了职责分离.但是在实际的编码实践过程中, ...

  8. Shell学习笔记之关于 >/dev/null 2>&1 详解

    shell中可能经常能看到:>/dev/null 2>&1 命令的结果可以通过%>的形式来定义输出 分解这个组合:“>/dev/null 2>&1” 为五 ...

  9. Mysql数据库中条件查询

    1.concat(字符串拼接) 作用:将选中的列进行拼接  写法 AS的作用就是属性名 SELECT CONCAT(ename,job) AS 你猜 FROM emp; 2.条件查询 语法: sele ...

  10. javascript Class.method vs Class.prototype.method(类方法和对象方法)

    在stackoverflow上看到一个这样的提问,以下代码有什么区别? Class.method = function () { /* code */ } Class.prototype.method ...