ios - 无法从 pod 库访问包

标签 ios swift xcode cocoapods bundle

我尝试在我的项目中使用 PEPhotoCropLibrary。我使用 cocoapods 安装程序添加了它。但是当我尝试在我的代码中使用它时,出现错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ' -[NSBundle initWithURL:]: nil URL argument'

这发生在这里:

NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"PEPhotoCropEditor" withExtension:@"bundle"];

然后我尝试在我的代码中访问 PEPhotoCropEditor.bundle:

let url = Bundle.main.url(forResource: "PEPhotoCropEditor", withExtension: "bundle")

并得到 nil 作为结果。项目结构在这里: enter image description here

这里有什么问题,为什么我无法访问库包?

最佳答案

请更改:

NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"PEPhotoCropEditor" withExtension:@"bundle"];

到:

NSURL *bundleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"PEPhotoCropEditor" withExtension:@"bundle"];

关于ios - 无法从 pod 库访问包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43681057/

相关文章:

iphone - Mac 在 MonoTouch 和 XCode 中开发的系统要求

ios - Gluon Mobile VideoService 在后台无法在 iphone 上运行

ios - 如何查看哪些 UICollectionView 单元格已滚动

objective-c - 将JSON对象导入NSArray

ios - 是否有任何示例/示例可用于使用适用于 iOS 的 Google People API?

swift - 有人可以向我详细解释如何正确地为 UIView 创建自定义初始化程序吗?

ios - 应用程序的测试版/开发者版本能否(并且应该!)使用与生产版本相同的 Apple App ID?

ios - swift 将副标题添加到饼图的中心

objective-c - 如何获取项目文件夹中以特定字符串开头的所有图像

swift - 如何在 appDelegate 方法上设置计时器计划?