I am trying to make my own cocoapods, I used images. When I follow the tutorial, I get an error.
.podspec
s.resource_bundles = {
'SSSlidingSelector' => ['SSSlidingSelector/Assets/*.xcassets']
}
Class/SlidingSelector.m
- (UIImage *)getImageWithName:(NSString *)imageName {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSURL *url = [bundle URLForResource:@"SSSlidingSelector" withExtension:@"bundle"];
NSBundle *targetBundle = [NSBundle bundleWithURL:url];
UIImage *image = [UIImage imageNamed:imageName
inBundle:targetBundle
compatibleWithTraitCollection:nil];
return image;
}
error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSBundle initWithURL:]: nil URL argument'
What is wrong with my code? thks
Nothing wrong with your code.
Cocoapods on version 1.0.1 supports Assets Catalogs. Please check if yours isn't below it running pod --version
in Terminal.
If a new pod install
does not solved, there is an issue with the xCode New Build System on Assets Catalogs (as mentioned Here) that could be your problem.
You can change the Build System on File
> Workspace Settings...
> Build System
. Try setting it to Legacy Build System
.