Incorporating Flutter into our existing iOS project enables some of the interface/functionality in our iOS project to be implemented via Flutter

  1. Xcode creates iOS project (here the project name is iOSFlutter, using Cocoapods)

  2. Create a fluttermodule by terminal command into the specified folder (the iOS project equivalent directory). Create a fluttermodule -t module myfluttermodule

  3. Xcode configuration

  • Set the project BitCode option to NO, which Flutter does not currently support
  • Create a Config connection file. Create a Config folder in the iOS projectConfiguration Settings FileFile namedFlutter.xcconfig. Debug.xcconfig. Release.xcconfigThree configuration files

The contents of the Flutter. Xcconfig file

//Flutter. Xcconfig, fill in the path Generated. Xcconfig of myFlutterModule#include ".. /.. /myfluttermodule/.ios/Flutter/Generated.xcconfig"
ENABLE_BITCODE=NO
Copy the code

Debug.xcconfig file contents

/ / pod path#include "Flutter.xcconfig"
#include "Pods/Target Support Files/Pods-iOSFlutter/Pods-iOSFlutter.debug.xcconfig"
Copy the code

Release.xcconfig

#include "Flutter.xcconfig"
#include "Pods/Target Support Files/Pods-iOSFlutter/Pods-iOSFlutter.debug.xcconfig"
FLUTTER_BUILD_MODE=release

Copy the code
  • Modify the Xcode Project environment configuration

  • Add the script content to execute

"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed
Copy the code

  1. Running Xcode normally generates a Flutter folder in the iOS project directory (if not, Then we will build a folder manually, the myfluttermodule/ios/Flutter of the App. The framework. The egine copy to the folder)

  2. At this point, you can directly execute the project that has been integrated with Flutter Xcode