UIImage +imageNamed:inBundle:compatibleWithTraitCollection: returns nil for resource bundles containing compiled asset catalogs
| Originator: | martin | ||
| Number: | rdar://24056523 | Date Originated: | 05-Jan-2016 04:58 PM |
| Status: | Behaves correctly | Resolved: | 26-Jan-2016 06:49 AM |
| Product: | iOS SDK | Product Version: | iOS 9.2 (13C75) |
| Classification: | Bug | Reproducible: |
Summary:
When attempting to use the +imageNamed:inBundle:compatibleWithTraitCollection: method of UIImage on a NSBundle containing a plain compiled asset catalog ("Assets.car"), it always returns nil.
Steps to Reproduce:
1. Create a bundle, separate from the main bundle, in an iOS project
2. Place a compiled asset catalog in the bundle ("Assets.car")
3. In the application code, load an image contained in the compiled asset catalog with +imageNamed:inBundle:compatibleWithTraitCollection:
Expected Results:
The +imageNamed:inBundle:compatibleWithTraitCollection: should return an UIImage with the image data of the image file contained in the asset catalog.
Actual Results:
nil is returned
Notes:
Attached is a sample project. Some notes:
• There is a "Sample.xcassets" image asset catalog that is not part of the main application bundle (and thus not the Xcode application target).
• There is a custom bundle "Custom.bundle" included in the Xcode application target via a folder reference.
• There is an image, "candle.png" in both the main application asset catalog, and in the sample asset catalog.
• Using a custom build script (see "Run Script" build phase), the "Sample.xcassets" is compiled into "Assets.car" inside the "Custom.bundle" bundle, using actool shell command.
• The UI contains two image views, +imageNamed:inBundle:compatibleWithTraitCollection: is used with the image name "candle" for each of the bundles to one image view each. As you can see in the application, only the first image view displays the image as intended.
• Problem is mentioned on the developer forums as well: https://forums.developer.apple.com/message/99742
Attachments:
'Bundle Bug.zip' was successfully uploaded. Can be downloaded at https://www.dropbox.com/s/w9kdk6yxgu1a01l/Bundle%20Bug.zip?dl=0
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Apple Response
Engineering has determined that this issue behaves as intended based on the following information:
The CustomBundle isn’t a bundle, it's just a directory; There is no info plist (which we need etc.).
CoreUI is behaving properly. We ask the bundle for its bundleIdentifier, and an empty directory returns nil.