title: Load image from CocoaPods resource bundle
body: <p>I am creating a private library that includes resources that are referenced by components in the library.  The library is shared with apps using CocoaPods.  In the .podspec for the library, I've included a line like this:</p>
  
  <pre><code>s.resource_bundles = {'IXMapKitResources' =&gt; ['IXMapKit/Resources/*']}
  </code></pre>
  
  <p>One of the resources in the bundle is an asset catalog with multiple image sets, one of which is called 'IXMKAnnotationIcons-Normal-Accident'.  The following code returns a nil:</p>
  
  <pre><code>UIImage * image = [UIImage imageNamed: @"IXMKAnnotationIcons-Normal-Accident"];
  </code></pre>
  
  <p>I found an <a href="http://www.mokacoding.com/2014/02/13/sharing-assets-with-cocoapods-resource-bundle-and-dynamically-loaded-fonts.html" rel="noreferrer">article on mokacoding.com</a> describing how to load fonts from a pod, but this didn't work for me:</p>
  
  <pre><code>- (UIImage *) ixmk_imageNamed: (NSString *) name
  {
      NSString * IXMKResourceBundleName = @"IXMapKitResources.bundle";
      NSString * resourceName = [NSString stringWithFormat: @"%@/%@", IXMKResourceBundleName, name];
  
      NSString * imageTypeString = [self ixmk_stringForImageType: imageType];
      NSURL * url = [[NSBundle mainBundle] URLForResource: resourceName withExtension: imageTypeString];
  
      NSData * imageData = [NSData dataWithContentsOfURL: url];
      if (imageData != nil)
      {
          CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef) imageData);
          CGImageRef imageRef = [self ixmk_imageFromDataProvider: provider imageType: imageType];
  
          UIImage * image = [UIImage imageWithCGImage: imageRef];
  
          CFRelease(imageRef);
          CFRelease(provider);
  
          return image;
      }
      else
      {
          return nil;
      }
  }
  </code></pre>
  
  <p>The <a href="http://guides.cocoapods.org/syntax/podspec.html#resources" rel="noreferrer">CocoaPods webpage describing the resources keyword</a> has the following warning:</p>
  
  <blockquote>
    <p>We strongly <strong>recommend</strong> library developers to adopt resource bundles as
    there can be name collisions using the resources attribute. Moreover
    resources specified with this attribute are copied directly to the
    client target and therefore they are not optimized by Xcode.</p>
  </blockquote>
  
  <p>I'm at a loss of what to do here.</p>