1. Configure a mirror

  1. Open the command terminal and enter the commandopen ~/.bash_profile, open the bash_profile text, add the image path and save it
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://flutter-io.cn
Copy the code

(This path will change, please follow the Flutter community for updates.)

  1. Command terminal, enter the commandsource ~/.bash_profile, the mirroring configuration takes effect

2. Configure flutterSDK

  1. Download the Flutter SDK and put it in a directory (I put it in the Documents directory)
  2. Enter the SDK path into the bash_profile and enter the commandopen ~/.bash_profile, open the bash_profile text, add the SDK file path and save it
export PATH=~/Documents/fluttersdk/bin:$PATH
Copy the code

Documents is the directory and FlutterSDK is the SDK folder

3. Execute the project through the command terminal

CD To the corresponding project and run the following command:

Flutter Emulator --launch apple_ios_simulator -- Flutter Emulator-d< device ID > Execute an emulatorCopy the code

4. Check whether Android and iOS dependencies are missing

Execute the Flutter Doctor on the terminal to look at the Android and iOS development environment. If the detected dependencies are missing, it will give you the installation result of the missing dependencies. Follow the prompts to install.

5. IOS Toolchain configuration – Can run on real iOS devices

Run related commands on the command terminal:

Brew update brew install --HEAD usbmuxd // usbmuxd is a socket daemon that establishes multiple communication connections with iOS devices. Brew Link USbMUxd brew install --HEAD LibiMobileDevice LibiMobileDevice is a cross-platform brew protocol library for communicating with iOS devices Install ideviceInstaller // IdeviceInstaller is a tool that uses them to manage apps on iOS devicesCopy the code

6. Android Toolchain configuration

Open the Android Studio app, go to Preferences > Plugins and search for the Flutter plugin and click Install to install

VS Code configuration

Open VS Code, go to View -> Command Palette, search for Flutter and click Install to install