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

没有这样的模块

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

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

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


当前回答

实际上,通过添加到build-debug.xconfig的末尾,我更容易地解决了这个问题

#包括“. ./Pods/目标支持文件/Pods- iap /Pods- iap .debug.xcconfig"

一直到build-release.xconfig的末尾

#包括“. ./Pods/目标支持文件/Pods- iap /Pods- iap .release.xcconfig"

因为这些文件已经定义了PODS_ROOT和相关的构建变量。

其他回答

在我的情况下,项目上的swift 4库没有编译,所以不可能找到它们并导入。 解决方案是将cocoapods库的编译版本设置为swift 3.2

有时豆荚分解,然后豆荚安装也帮助我。

我的问题是有多个目标。 我用以下链接解决了这个问题: 配置pod文件正确的方式和修复构建设置

希望有人会觉得有用。

几天前我也遇到了同样的错误。下面是我解决这个问题的方法:

错误是“模块未找到”

Create Podfile in your root project directory Install cocoapods (a dependency manager for Swift and iOS projects) Run pod install Go to Project Build Settings: Find Objective-c bridging Header under Swift compiler - Code Generation (If you don't find Swift compiler here, probably add a new Swift file to the project) Drag and drop the library header file from left side to bridging header (see image attached) Create a new bridging header file: e.g TestProject-Bridging-Header.h and put under Swift Compiler → Objective-C Generated Interface Header Name (ref, see the image above) In TestProject-Bridging-Header.h file, write #import "Mixpanel/Mixpanel.h" In your Swift file the code should be: Import Mixpanel (i.e name of library)

这是所有。

我赢得了“没有这样的模块”错误的最愚蠢原因奖。在我的例子中,我手工构建了包含的框架,并将其复制到我的项目目录中。我的框架搜索路径设置正确,框架也被正确地添加到项目中。

当我归档我正在构建的框架时,我使用“Show in Finder”将我带到派生数据中的发布文件夹。但是我没有注意到这个文件夹只包含框架的别名,而不是框架本身。原始框架仍然在我的派生数据目录中,所以后来当我清除派生数据时,框架被删除了,但我的项目不知道这一点。

重新归档框架,遵循别名到实际框架,并将其复制到我的项目目录中,这是可行的。