Interface builder displays image from framework but the image loading fails at runtime

Originator:alin.claudiu.radut
Number:rdar://FB7721289 Date Originated:06.01.2020
Status:Open Resolved:
Product:Xcode Product Version:11.5
Classification:Bug Reproducible:Yes
 
Please provide a descriptive title for your feedback:
Interface builder displays image from framework but the image loading fails at runtime

Which area are you seeing an issue with?
Xcode

What type of feedback are you reporting?
Incorrect/Unexpected Behavior

Details
What version of Xcode are you using?
Xcode 11.5

Description

Please describe the issue:
When trying to load an asset from another framework, Interface Builder correctly displays the image in the image view. When ran on a device/simulator the image loading will fail. 

This can be mitigated by loading the image from code using the appropriate bundle hint, however in that case setting images to image views from Interface Builder becomes useless. At the moment, being able to pick an image from a secondary bundle leads to false expectations.

I think this could be solved by allowing the user to specify the module to load the image from (either via a "BundleName/image" syntax or by a dropdown), similar to how we load custom classes from other modules.

Please list the steps you took to reproduce the issue:
Create an iOS project, add a framework and add a Media.xcassets catalog to this framework. Add an asset to this catalog. Back in the main project open the storyboard and add an image view and assign the asset as the image for this image view. Run the application.

What did you expect to happen?
The icon should be displayed on the screen in the attached image view.

What actually happened?
The image view remains blank and a warning is produced in the console: 
Could not load the "xcode" image referenced from a nib in the bundle with identifier "com.example.ImageLoading"

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!