Recently, the unit project involved flutter mixing, so I went to the official document to learn about it. Here I will make a brief record and translate the translation. Convenient for everyone to learn from each other.


If a folder contains iOS projects and a Flutter project does not have a Flutter project, please execute the following command line

CD Project path flutter create --template module my_flutterCopy the code

As shown in the figure below

Plan A

  1. In the iOS projectPodfileThe headadd
flutter_application_path = '.. /my_flutter' load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')Copy the code
  1. And then add
target 'MyApp' do
Copy the code
  1. As is shown in

  1. pod install

Plan B Manually import Framework

  1. CD/my_flutter path
  2. Flutter build ios-framework --output= here splices the path you want to output the framework to
  3. At this point, three folders will be generated under this path, respectivelyDebug,Profile,Release
  4. Manually import one of the foldersApp.frameworkandFlutter.frameworkAnd,BuildSetting -> Framework Search PathsTo have the path where the framework was just exported, for example:"$(SRCROOT)/.. /Debug"It’s fine to drag folders in, but make sure you don’t have path problems later.

Plan C is similar to Plan B, using Cocoapods

  1. CD/my_flutter path

  2. Flutter build ios-framework --cocoapods --output= here splices the path you want to export the framework to

  3. In this case, three folders are also generated, namely Debug, Profile, and Release, but the contents are different from Plan B

  4. Then, inPodFilePodspec => ‘some/path/MyApp/Flutter/[build mode]/Flutter. Podspec ‘. As shown in the figure, of course, this is just a demonstration, not considering the relative path problem for the time being!! Please pay attention to.

  5. Received imported into the corresponding folderApp.frameworkAnd the same as steps 4 and 5 in Plan B, make sure