GitHub:github.com/baiyuliang/…

First of all, if you have never run the Flutter application on MacOS before, you will probably get an error when you create FlutterProject and run it on the IOS emulator after installing AndroidStudio and configuring the Flutter environment for the first time:

CocoaPods not installed...
Copy the code

Install CocoaPods:

$ sudo gem install cocoapods
Copy the code

But I have been failing in installation:

Failed to build gem native extension...
Copy the code

Solutions that work for me:

1. Replace the Homebew source:

$ /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Copy the code

Choose 5 Alibaba sources.

2. Enter Y to confirm the command.

3. If you are prompted to enter the password, enter the preset system password.

4. Update the Ruby version by replacing the RVM source first:

Remove foreign sources:

$ gem sources --remove https://rubygems.org/
Copy the code

Add domestic source:

$ gem sources -a https://gems.ruby-china.com/
Copy the code

Install the latest version of Ruby:

$RVM install 3.0.2Copy the code

At this point, install Cocoapods again:

$ sudo gem install cocoapods
Copy the code

It will be installed soon!

If our Flutter project is created on Windows and running on Android, we will encounter the same problems when transferring the project to Mac and trying to build IOS apps. The solution here is to import the Flutter project on Mac:

Delete the above files, as well as the build and Pods directories in the IOS folder, if any, then open pubspec.yaml and execute pub Get!

Finally, open the ios emulator and run the project. Flutter automatically compiles the ios runtime environment!

If prompted:

The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99
Copy the code

You can open up your iPod File on ios,

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
Copy the code

Add:

post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) target.build_configurations.each do |config| Config. build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0' end End EndCopy the code

If prompted:

The application's Info.plist does not contain CFBundleVersion.
Copy the code

Then open info.plist and change the CFBundleVersion to a fixed value.