我目前在Swift编码,我有一个错误:
没有这样的模块
但我不明白,因为这个模块在我的项目中,在“链接框架和库”和“嵌入式二进制文件”中声明。
框架是在Objective-C中,所以我为它写了一个桥标头。
请问,如何让Xcode识别框架?
我目前在Swift编码,我有一个错误:
没有这样的模块
但我不明白,因为这个模块在我的项目中,在“链接框架和库”和“嵌入式二进制文件”中声明。
框架是在Objective-C中,所以我为它写了一个桥标头。
请问,如何让Xcode识别框架?
当前回答
几天前我也遇到了同样的错误。下面是我解决这个问题的方法:
错误是“模块未找到”
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)
这是所有。
其他回答
对我来说,这发生在RxSwift上,问题是我在Podfile中将其修复为3.0.0。移除版本限制并更新pods将其升级到3.1.0,从而修复了它。
在Xcode 10.1中,我的解决方案是在文件菜单中的工作区设置中改变构建系统。它默认设置为New Build System,将其更改为Legacy Build System,这就成功了。
我在使用Cocoapods和Swift时也遇到了同样的问题。我没有注意到Podfile中的以下行:
# Uncomment this line if you're using Swift
# use_frameworks!
所以,我所要做的就是把它改成:
# Uncomment this line if you're using Swift
use_frameworks!
...啊,它起作用了:)
在我的情况下,项目上的swift 4库没有编译,所以不可能找到它们并导入。 解决方案是将cocoapods库的编译版本设置为swift 3.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)
这是所有。