现在我想把我的ObjC框架迁移到Swift,我得到了以下错误:

include of non-modular header inside framework module 'SOGraphDB'

引用是一个头文件,它只是定义了一个协议,我在一些类中使用这个头文件来使用这个协议。

这似乎与模块特性有关,但目前不太清楚如何修复,你知道解决方案吗?

更新:

这是一个Swift编译器错误。

更新2:

一个快速的解决方法(但不能解决根本原因)是将以下设置设置为yes: clang_allow_non_modular_incles_in_framework_modules = yes


当前回答

下面是如何自动应用快速修复,这样你就不必更换Pods了。在每个pod安装后手动Xcodeproj。

将这个片段添加到Podfile的末尾:

post_install do |installer|
  installer.pods_project.build_configuration_list.build_configurations.each do |configuration|
    configuration.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
  end
end

其他回答

头文件已分配给目标,但仅被标记为项目可见,只是更改为公共导致解决此错误。

Most commonly this error is caused by the chosen answer, yet I had this error appear once by accident when dragging framework files into my new project folder. I clicked to delete the frameworks but accidentally pressed to only 'Remove Reference' to the frameworks rather than to actually delete the files completely. At this point if I opened my project folder in Finder I saw files like 'CoreLocation' and 'AudioToolbox' there. Deleting these files from the project folder and cleaning the project fixed the issue.

我解决了它从框架中删除模块文件夹。

使用finder浏览到应用程序项目中显示的框架位置 进入Test.framework文件夹(在上面的例子中,它将是SOGraphDB.framework) &删除模块文件夹。 清洁和重新构建应用程序,它将解决问题。

导入Parse框架时遇到了这个问题。我能解决这个问题的唯一方法是放弃我上次提交后所做的所有更改(简单地删除框架并清理项目不起作用),并再次添加Parse(在重新下载SDK之后)及其所需的其他框架。

我在将一个项目从swift2更新到swift3后遇到了这个问题。我使用XCode 8.3.2更新代码,无法摆脱“框架模块内的非模块化头”的错误。当我在另一个版本的XCode(版本9.0.1)中打开相同的项目时,错误没有出现。