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

没有这样的模块

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

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

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


当前回答

我的问题(这一次)是我在Podfile中使用了一个过时的库版本。

我使用:

pod 'LBTAComponents', '~> 0.1.9'

这并没有起作用,但当我把它改成:

pod 'LBTAComponents', '~> 1.0.2'

它工作。

其他回答

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

错误是“模块未找到”

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)

这是所有。

我发现构建设置中的导入路径是错误的自定义(MySQL)模块。把它指向正确的方向后,信息就消失了。

确保Scheme中的“在构建中查找隐式依赖项”选项是打开的!

我在加载FacebookSDK时遇到了类似的问题,我添加了~/Documents/FacebookSDK(搜索你的框架在哪里)到构建设置中的框架搜索路径,之后我就可以导入FBSDKShareKit模块了

此错误也可能由框架缺少模块映射引起。如果您试图导入的框架是您自己的框架,请检查框架本身的编译器警告。在我的情况下,我的框架正在构建和到位,但有一个构建警告:

警告:没有为目标'MyFramework'找到伞头,模块映射将不会生成

通过解决这个警告(与框架头不匹配模块名有关),我能够导入框架。