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

没有这样的模块

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

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

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


当前回答

这是最后对我有用的方法。我不得不做这一切,这很蹩脚,但这是我能找到的唯一有效的方法。

在确保图书馆被列在链接框架和图书馆。如果没有,你可以点击+,希望能看到你的框架/pod。

在方案图标中单击您的项目(见下图)

然后你会看到你的关注点框架:

单击“管理方案”。

然后你会看到如下内容:

勾选框架的方框,单击自动创建方案,然后关闭。

然后尝试再次导入框架/pod。

这对我很管用。

其他回答

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)

这是所有。

在我的例子中,我只需要重新加载项目。我使用命令行克隆我的项目,但它没有正确安装子模块。为了补救,我通过XCode克隆了项目,一切正常。只是要确保先备份所有更改。

我不知道为什么会发生这种情况,但解决你的问题的一种方法是进入你的构建设置并定义框架搜索路径到一个包含有问题的框架的文件夹。如果框架放在您的项目目录中,只需将框架搜索路径设置为$(SRCROOT)并将其设置为递归。

在podfile中,删除产生问题的pod,并保存该文件 运行pod安装 重新添加pod,保存文件 重新运行pod安装