This article documents the general idea you need to know before starting to install your environment and the author’s installation process

I. Installation overview

You need to install the following:

  • brew
  • xcode
  • Androidstudio or vscode
  • android sdk
  • flutter sdk
  • dart sdk

Second, detailed process

1, xcode,

Xcode is what we need to develop and compile ios. You can download and install it directly in App Store.

2, the brew

Brew is a package management tool for MAC, equivalent to Ubuntu apt-get and centos yum. The toolkit is not installed on MAC by default, so you need to install it manually.

1. Rely on Command Line Tools

Open the terminal and type xcode-select –install

2. Install BREW

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

If the installation fails, probably due to network reasons, re-execute the BREW installation command

3. Switch brew source

1. Replace brew.git

Homebrew is hosted on Github, and updating Homebrew means pulling the latest version from Git. Sometimes Git is too slow to update, so you need to change your git repository to a remote location.

cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
Copy the code
2. Replace homebrew-core.git

Replace the address of the Homebrew core software repository.

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
Copy the code
3, replace Homebrew Bottles Ali mirror source

The official pre-compiled software will be installed in a bottle and directly downloaded and decompressed into the system, without local compilation. The Bottle was on top of the bintray, which is still not happy in Korea. You can speed up the download of bottle by changing the source address of bottle

For bash users:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
Copy the code

For ZSH users:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
Copy the code

Install Androidstudio and vscode

4. Android SDK configuration

Download the Android SDK and configure the environment variables

Export ANDROID_HOME= Your Android SDK installation directory export PATH=$PATH:$ANDROID_HOME/tools export PATH=$PATH:$ANDROID_HOME/platform-toolsCopy the code

Update the configured environment variables by running the source ~/.bash_profile command

5. Configure flutter environment variables

Download the Flutter SDK, extract it to the folder you want to place it in, and then configure the environment variables

Export FLUTTER_ROOT= Your FLUTTER installation directory export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn export PATH= your FLUTTER installation directory /bin:$PATHCopy the code

Update the configured environment variables by running the source ~/.bash_profile command

Once the environment variables are configured, the flutter command can be used.

6. Configure dart environment variables

Download the Dart SDK, extract it to your custom directory, and configure the environment variables

export DART_HOME=/Users/xxx/sdk/flutter/bin/cache/dart-sdk/bin
export PATH="${DART_HOME}:${PATH}"
Copy the code

Dart –version returns the version number and succeeds.

Three, possible problems

Run the Flutter Doctor after installation to see if the environment is ready

1, Some Android licenses not accepted

Run flutter Doctor — Android-Licens as prompted

2. Cocopods installation problem

CocoaPods is a Ruby tool for managing third-party open source libraries in your iOS projects. It allows you to centrally manage your third-party open source libraries and saves you time on setting up and updating your third-party open source libraries.

Error when using su gem install cocopods as prompted

ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension. current directory: / Library/Ruby/Gems / 2.3.0 / Gems/ffi - 1.12.2 / ext/ffi_c/System/Library/Frameworks/Ruby framework Versions / 2.3 / usr/bin/Ruby -i /Library/Ruby/Site/2.3.0 -r./siteconf20200303-68332-1cf9u3w.rb extconf.rb MKMF. Rb can't find header files for Ruby Ats/System/Library/Frameworks/Ruby framework Versions / 2.3 / usr/lib/Ruby/include/Ruby. H extconf failed, The exit code 1 Gem files will remain installed in/Library/Ruby/Gems / 2.3.0 / Gems/ffi - 1.12.2 for inspection. The Results logged To/Library/Ruby/Gems / 2.3.0 / extensions/universal - Darwin - 18/2.3.0 ffi - 1.12.2 / gem_make. OutCopy the code

Find a solution for reference.

Finally, running the Flutter Doctor has no error entries and the environment is installed.