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

没有这样的模块

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

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

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


当前回答

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

其他回答

我在使用Cocoapods和Swift时也遇到了同样的问题。我没有注意到Podfile中的以下行:

# Uncomment this line if you're using Swift
# use_frameworks!

所以,我所要做的就是把它改成:

# Uncomment this line if you're using Swift
use_frameworks!

...啊,它起作用了:)

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

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

错误是“模块未找到”

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)

这是所有。

如果是周五下午或凌晨1点之后:

打开xcodeproj而不是xcworkspace将导致如下错误…

在我的例子中,应用IPHONEOS_DEPLOYMENT_TARGET被设置为9.3,而在我新创建的框架中,它被设置为10.2

隐式依赖解析器忽略了我的新框架,因为目标平台的要求高于应用程序的要求。

在调整框架iOS部署目标以匹配我的应用程序部署目标后,框架编译并链接成功。