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

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

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

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

更新:

这是一个Swift编译器错误。

更新2:

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


当前回答

对我来说,解决方案是去目标->构建设置->允许框架模块中的非模块化包含切换到YES!

其他回答

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) &删除模块文件夹。 清洁和重新构建应用程序,它将解决问题。

我尝试了我在这个线程上找到的所有可能的解决方案,设置目标->构建设置->允许框架模块中的非模块化包含切换到YES!等等。

但是什么都不管用。

当我通过评论use_frameworks安装pods时,我开始得到这个错误!,因为我想有一个静态库的豆荚。

原因Swift编译器抛出(在Xcode 13)这个错误,因为我正在导入私有框架头#导入“TFLTensorFlowLite.h” 在公共.h文件中,所以我在.m文件中导入了它,如下面的截图所示,它停止了Swift编译器抛出这个错误(注意我的框架有Objective c和Swift代码)

允许框架模块中的非模块化包含为YES!为我解决了同样的问题。

对我来说,解决方案是去目标->构建设置->允许框架模块中的非模块化包含切换到YES!