Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在cocoapods中加载资源包错误_Ios_Objective C_Cocoapods_Nsbundle - Fatal编程技术网

Ios 在cocoapods中加载资源包错误

Ios 在cocoapods中加载资源包错误,ios,objective-c,cocoapods,nsbundle,Ios,Objective C,Cocoapods,Nsbundle,我试着做我自己的椰子荚,我用图像。 当我遵循教程时,我会遇到一个错误 .podspec s.resource_bundles = { 'SSSlidingSelector' => ['SSSlidingSelector/Assets/*.xcassets'] } Class/slidengselector.m -(UIImage*)getImageWithName:(NSString*)imageName{ NSBundle*bundle=[NSBundle bundle

我试着做我自己的椰子荚,我用图像。 当我遵循教程时,我会遇到一个错误

.podspec

  s.resource_bundles = {
    'SSSlidingSelector' => ['SSSlidingSelector/Assets/*.xcassets']
  }
Class/slidengselector.m

-(UIImage*)getImageWithName:(NSString*)imageName{
NSBundle*bundle=[NSBundle bundleForClass:[self class]];
NSURL*url=[bundle URLForResource:@“SSSlidingSelector”及其扩展名:@“bundle”];
NSBundle*targetBundle=[NSBundle bundlewithur:url];
UIImage*image=[UIImage imageName:imageName
内置:targetBundle
与traitcollection兼容:nil];
返回图像;
}
错误

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSBundle initWithURL:]: nil URL argument'
屏幕截图

我的代码有什么问题?
thks

您的代码没有问题

版本1.0.1上的Cocoapods支持资产目录。请检查您的电脑是否在终端中运行
pod--version

如果一个新的
pod安装没有解决,那么资产目录上的xCode新构建系统(如上所述)就可能是您的问题

您可以在
文件
工作区设置…
生成系统
上更改生成系统。尝试将其设置为
旧版生成系统


我刚刚测试了此功能,功能正常运行。您正在使用哪一版本的Cocoapods?1.7.5@alxlives
- (UIImage *)getImageWithName:(NSString *)imageName {
    NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    UIImage *image = [UIImage imageNamed:imageName
                                inBundle:bundle
           compatibleWithTraitCollection:nil];
    return image;
}