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

没有这样的模块

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

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

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


当前回答

Sazzad Hissain Khan的3分。选项添加相同的“构建配置”在应用程序的框架,而不是在应用程序解决了我的“未知模块”问题。

这篇文章帮助我了解如何添加新的构建配置,因为进入编辑器->添加配置是灰色的

在Xcode中添加构建配置

其他回答

TL;DR:检查Podfile中特定于目标的shared_pods

在绞尽脑汁尝试了上周贴在这里的每一个答案之后,我终于找到了一个解决方案。

我有两个独立的目标——一个用于发布,一个用于开发。开发目标是在发布目标之后很久才创建的,这导致我忘记了该目标的一些设置步骤。

我能够使用我的发布目标正确地编译我的项目,但是我的开发目标遇到了一个问题。

在第20次查看我的Podfile后,我注意到在我的shared_pods定义下只有以下内容:

target 'Release' do
  shared_pods
end

我需要做的是将我的第二个目标添加到我的Podfile中,这就解决了这个问题:

target 'Release' do
  shared_pods
end

target 'Development' do
    shared_pods
end

希望这能让一些人少受几天的困扰。

Another possible cause in XCode 10 can be the Supported Platforms sometimes gets changed to macOS and the Valid Architectures gets changed to i386 x86_64 for the Pods Projects. Assuming the project is for iOS, then select the Pods Project and change the Supported Platforms to iOS and the Valid Architectures to arm64 arm64e armv7 armv7s, You could do each of the Targets, however that takes longer if you have more than one Pod. Also the Swift version of frameworks in written Swift sometimes gets set to the wrong version.

对于那些有多个目标的人,检查是否在正确的目标上添加了框架。(在框架、库和嵌入式内容中)。

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

错误是“模块未找到”

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)

这是所有。

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