我目前在Swift编码,我有一个错误:

没有这样的模块

但我不明白,因为这个模块在我的项目中,在“链接框架和库”和“嵌入式二进制文件”中声明。

框架是在Objective-C中,所以我为它写了一个桥标头。

请问,如何让Xcode识别框架?


当前回答

有几个潜在的错误配置可能会导致这个问题,

Please confirm that you have opened the .xcworkspace but not .xcodeproj file. Also make sure you have build Social first before you build TriviaApp. Make sure that iOS Deployment Target is set same for all modules with main app. For example is TriviaApps deployment target is set to 9.0, Socials deployment target also need to be set to 9.0. Make sure your main module (TriviaApp) and your used framework (Social) have same set of configurations. i.e. If your Project has three configurations, Debug, Release, ReleasePremium than your Social framework also need to have three configurations Debug, Release, ReleasePremium. Also make sure that the archive configuration is set same for both TriviaApp and Social. i.e. if your TriviaApps archive scheme is set to ReleasePremium, your Socials archive scheme also need to be set into ReleasePremium. Please assure that you do not need to import Social in each .swift files when its already added in the Bridging-Header.h. In case of issue came from Pod files, make sure you have uncommented #use_frameworks! into use_frameworks! from you Podfile. Sometime re installing pod works if Social has any dependency on pods. If none of the above steps works, delete your derived data folder and try re building.

其他回答

假设框架真的在那里,在道路上,等等……删除~/Library/Developer/Xcode/DerivedData/ModuleCache目录(清理项目并删除项目特定的派生数据)。

在执行标准清理时,不会重新构建ModuleCache目录。

在尝试了这个线程上的所有想法后,当我更新cocoapods时,它起作用了。

$ pod --version
$ 1.0.0 // should have been 1.10.0

你应该更新cocoapods

gem which cocoapods

如果你做了以上所有的事情,仍然没有工作,然后尝试在你的目标构建设置的框架搜索路径中添加$(inherited)。

我不知道为什么会发生这种情况,但解决你的问题的一种方法是进入你的构建设置并定义框架搜索路径到一个包含有问题的框架的文件夹。如果框架放在您的项目目录中,只需将框架搜索路径设置为$(SRCROOT)并将其设置为递归。

我安装了pod Fakery, pod被添加到我的Pods文件下,但是当我尝试使用它时,我得到了同样的错误。问题是,我没有构建它,在构建它之后,swift编译器在Fakery swift文件中抛出了一些错误,一些函数已经被重命名,它也为它们提供了修复。在解决了所有这些编译器问题后,构建成功了,我能够使用模块。所以快速的语言兼容性是我的问题。