我尝试在我的项目中使用 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")
这里有什么问题,为什么我无法访问库包?
最佳答案
请更改:
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/