使用Xcode遇到错误“没有这样的模块”,但是框架在那里

本文翻译自:Getting error “No such module” using Xcode, but the framework is there

I'm currently coding in Swift, and I've got an error: 我目前正在使用Swift进行编码,但出现错误:

No such module Social 没有这样的模块社交

But I don't understand, because the module is in my project, declared in "Linked frameworks and Libraries" and in "Embedded Binaries". 但是我不明白,因为该模块在我的项目中,在“链接的框架和库”和“嵌入式二进制文件”中声明。

The frameworks is in Objective-C, so I wrote a Bridge Header for it. 这些框架位于Objective-C中,因此我为此编写了一个桥头。

Please, how can I make Xcode recognize the framework? 请,如何使Xcode识别框架?

使用Xcode遇到错误“没有这样的模块”,但是框架在那里

使用Xcode遇到错误“没有这样的模块”,但是框架在那里

使用Xcode遇到错误“没有这样的模块”,但是框架在那里

使用Xcode遇到错误“没有这样的模块”,但是框架在那里


#1楼

参考:https://stackoom.com/question/1zmM7/使用Xcode遇到错误-没有这样的模块-但是框架在那里


#2楼

Assuming the Framework really is there and in the path, etc... delete the ~/Library/Developer/Xcode/DerivedData/ModuleCache directory (and clean the project and delete the project-specific derived data for good measure). 假设Framework确实存在并且在路径中,等等,...删除〜/ Library / Developer / Xcode / DerivedData / ModuleCache目录(并清理项目并删除项目特定的派生数据,以备不时之需)。

When you do the standard cleanup, the ModuleCache directory doesn't get rebuilt. 当您执行标准清理时,不会重建ModuleCache目录。


#3楼

I'm not sure why this happens, but one way to solve your issue is to go into your build settings and defining the Framework Search Paths to a folder which contains the frameworks in question. 我不确定为什么会这样,但是解决您的问题的一种方法是进入构建设置,并定义指向包含相关框架的文件夹的框架搜索路径 If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT) and set it to recursive. 如果将框架放置在您的项目目录中,只需将框架搜索路径设置为$(SRCROOT)并将其设置为递归。


#4楼

Ok, how the same problem was resolved for me was to set the derived data location relative to the workspace directory rather than keeping it default. 好的,对我来说,解决同一问题的方法是设置相对于工作区目录的派生数据位置,而不是将其保留为默认值。 Go to preferences in xcode. 转到xcode中的首选项。 Go to locations tab in preferences and set Derived data to Relative. 转到首选项中的“位置”选项卡,并将“派生数据”设置为“相对”。 Hope it helps. 希望能帮助到你。


#5楼

I am not quite sure why Martin R 's answer in the comments for the question is so disregarded: 我不太确定为什么马丁·R在问题评论中的回答如此被忽略:

Make sure that you tried simply skipping import of the framework as it is already added with the bridging header . 确保已尝试仅跳过框架的导入,因为该框架已与桥接头一起添加

Hope this helps 希望这可以帮助


#6楼

In case it's Friday afternoon or anytime after 1am: 如果是星期五下午或凌晨1点之后的任何时间:

Opening xcodeproj instead of xcworkspace will cause an error like this... 打开xcodeproj而不是xcworkspace会导致这样的错误...