Download the latest installer from the Flutter SDK version list or just git clone.

1
git clone https://github.com/flutter/flutter.git -b stable

Add the path to the downloaded and unpacked file to the environment variable. For example, on Linux and macOS Mojave and earlier systems, Bash Terminal is used by default, so you need to modify the $HOME/.bashrc file, while macOS Catalina systems use Z Shell by default, so you need to modify the $HOME/.zshrc file.

1
2
3
4
export PATH="$PATH:[PATH_OF_FLUTTER_DIRECTORY]/bin"

//Check if it has been added to the PATH environment variable
echo $PATH

Run source $HOME/.bash_profile to refresh the current terminal to take effect.

Verify that the flutter command is available.

1
which flutter

Check if the current environment requires additional dependencies to be installed.

1
flutter doctor -v

Setting up the iOS development environment

Make sure Xcode is installed.

1
2
sudo xcode-select -s /Applications/Xcode.app
sudo xcodebuild -runFirstLaunch

Create a new Flutter App

1
flutter create easeapi_app

Two ways to open a project.

  • Use Android Studio to open

    Open Preferences > Plugins in Android Studio and search for Flutter and Dart plugins to install. Use Android Studio > Open an existing Android Studio project to open the easeapi_app directory, you can directly select the iOS simulator to run.

  • Open with Xcode

    Open the ios/Runner.xcworkspace project directly via Xcode.

Set package name and developer Team for iOS project

flutter provides commands to automate the build.

1
flutter build ios --debug

You need to configure the package name and developer team of the project before using it.

Open the project via Xcode: TARGETS > Signing & Capabilities.

Add Podfile for the newly created Flutter App

1
2
cd ios
vim Podfile
1
2
3
4
5
platform:ios, '11.0'
source 'https://cdn.cocoapods.org/'
target 'Runner' do
    pod 'EaseapiCom', :path => './'
end

Execute: pod install, and an error will occur.

1
CocoaPods did not set the base configuration of your project because your project already has a custom config set.

This is because flutter and Cocoapods both generate xcconfig files for the corresponding PROJECT, flutter has already generated xcconfig, and executing pod install will prompt that the file already exists. At this point, the xcconfig configuration for Cocoapods is not in effect.

You can manually introduce the xcconfig file generated by pod install into the xcconfig file generated by flutter. The procedure is as follows.

1
2
3
4
vim ios/Flutter/Debug.xcconfig

#include "Generated.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
1
2
3
4
vim ios/Flutter/Release.xcconfig

#include "Generated.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"

Once the above configuration is complete, run Runner.xcworkspace directly with Xcode.