为什么我的项目代码不能访问我的CocoaPods?

时间:2022-10-11 00:33:10

I'm using CocoaPods to add SnapKit to my iOS project. However, none of the functions from SnapKit are accessible from my source code. Xcode immediately throws a compiler warning along this lines of "this doesn't exist"

我正在使用CocoaPods将SnapKit添加到我的iOS项目中。但是,我的源代码中无法访问SnapKit中的任何功能。 Xcode立即抛出编译器警告“这不存在”

I followed the install instructions listed here. I also have the xcworkspace open that CocoaPods created and I see my app project and a Pods project. I did notice that under Pods/Product in the navigator I see Pods.framework and SnapKit.framework in red. When I run find . | grep SnapKit.framework in my project directory, nothing turns up.

我按照此处列出的安装说明操作。我还打开了CocoaPods创建的xcworkspace,我看到了我的app项目和一个Pods项目。我注意到在导航器中的Pods / Product下,我看到Pods.framework和SnapKit.framework为红色。当我跑步时找到。 | grep SnapKit.framework在我的项目目录中,什么都没有出现。

After digging around I believe SnapKit.framework is in my DerviedData folder under ~/Library/Developer/XCode. I did notice that under the build settings for Pods PODS_FRAMEWORK_BUILDPATH is set to look in a builds directory under my project, which does not exist. Perhaps that's the issue? Are my pods supposed to build in a build directory? How would I make them do that?

在挖掘之后,我相信SnapKit.framework位于〜/ Library / Developer / XCode下的DerviedData文件夹中。我注意到在Pods的构建设置下,PODS_FRAMEWORK_BUILDPATH被设置为查看我的项目下的构建目录,该目录不存在。也许那就是问题?我的pod应该构建在构建目录中吗?我怎么能让他们这样做?

Additionally, both my project and the library are written entirely in swift.

另外,我的项目和库都是完全用swift编写的。

3 个解决方案

#1


I guess you missing something very simple like:

我猜你错过了一些非常简单的东西:

import SnapKit

This will solve your issue

这将解决您的问题

#2


I encountered a similar issue after installing SnapKit with CocoaPods.

在使用CocoaPods安装SnapKit后,我遇到了类似的问题。

I performed the installation correctly and inserted the import SnapKit line as required, but my project simply was not recognising the SnapKit framework. The import line produced a "no such module" error.

我正确执行了安装并根据需要插入了导入SnapKit行,但我的项目根本没有识别SnapKit框架。导入行产生了“无此模块”错误。

So I tried building the project without SnapKit and then like magic the SnapKit framework was recognised after that. I put back the import SnapKit line and everything started working as expected.

所以我尝试在没有SnapKit的情况下构建项目,然后像魔术那样在之后识别出SnapKit框架。我放回导入的SnapKit线,一切都按预期开始工作。

#3


I'm almost entirely certain that this is an edge case just for me, but I was editing a podfile and installing in the Trash.

我几乎完全确定这只是一个适用于我的边缘情况,但我正在编辑一个podfile并安装在垃圾桶中。

Definitely picking the correct folder helped ;)

绝对选择正确的文件夹帮助;)

#1


I guess you missing something very simple like:

我猜你错过了一些非常简单的东西:

import SnapKit

This will solve your issue

这将解决您的问题

#2


I encountered a similar issue after installing SnapKit with CocoaPods.

在使用CocoaPods安装SnapKit后,我遇到了类似的问题。

I performed the installation correctly and inserted the import SnapKit line as required, but my project simply was not recognising the SnapKit framework. The import line produced a "no such module" error.

我正确执行了安装并根据需要插入了导入SnapKit行,但我的项目根本没有识别SnapKit框架。导入行产生了“无此模块”错误。

So I tried building the project without SnapKit and then like magic the SnapKit framework was recognised after that. I put back the import SnapKit line and everything started working as expected.

所以我尝试在没有SnapKit的情况下构建项目,然后像魔术那样在之后识别出SnapKit框架。我放回导入的SnapKit线,一切都按预期开始工作。

#3


I'm almost entirely certain that this is an edge case just for me, but I was editing a podfile and installing in the Trash.

我几乎完全确定这只是一个适用于我的边缘情况,但我正在编辑一个podfile并安装在垃圾桶中。

Definitely picking the correct folder helped ;)

绝对选择正确的文件夹帮助;)