Flutter 混编(Xcode)的坑

1、关闭bitcode 

2、File -> WorkSpace Setting -> Legacy build system

3、若是插件中有swift实现的,但是原项目中是纯OC,可以新建个.swift 文件,然后create bridge ,并注意Build Settings中的swift的相关设置

4、cd到文件夹下,新建flutter_module的flutter项目,新建完毕之后将自己的dart代码等全部拖进去

flutter create -t module flutter_module

Flutter 混编(Xcode)的坑_第1张图片

5、PodFile中的设置(XXX是项目名称),并pod install

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'YJSchool' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!

  # Pods for TestOne

end

#新添加的代码
flutter_application_path = '../flutter_module'
eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)

 

Flutter 混编(Xcode)的坑_第2张图片

 

6、将flutter_module文件夹中的.ios下的Flutter中的App.frameWork和engin中的Flutter.framework拷贝到XXX项目中,

Flutter 混编(Xcode)的坑_第3张图片

 

7、再将上面的App.framework中的flutter_assets文件夹拷贝到桌面,并在XXX项目中这样添加

 

8、在Build Phases中,新建

Flutter 混编(Xcode)的坑_第4张图片

 

并写入: (注意下面的embed,不行可以删掉)

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

 

并拖动至:

Flutter 混编(Xcode)的坑_第5张图片

你可能感兴趣的:(Flutter)