I have struggled a lot to how to load resource in cocoapods resource_bundle.
The following is what i put in the .podspecs file.
s.sourc
Just for the record: I wanted to open a NIB from a Category stored in a CocoaPods library. Of course [self classForCoder] gave UIKit back (because of the Category), so the above methods didn't work.
I resolved the issue using some hardcoded paths:
NSURL *bundleURL = [[[NSBundle mainBundle] resourceURL] URLByAppendingPathComponent:@"Frameworks/MyCocoaPodLibraryName.framework"];
NSBundle *podBundle = [NSBundle bundleWithURL:bundleURL];
CustomView *customView = [[podBundle loadNibNamed:@"CustomView" owner:self options:nil] firstObject];
This will work
In .podspec add s.resources in addition to s.resource_bundles (pod install afterwards)
s.resources = 'XDCoreLib/Pod/Resources/**/*.{png,storyboard}'
Then in your code, its as easy as:
let image = UIImage(named: "image_name.png", in: Bundle(for: type(of: self)), compatibleWith: nil)
Note: You may need to run pod install after updating the .podspec to have the changes to your Xcode proj