IBDesignables Agent Crashes on Named Colors in Asset Catalog unless Bundle is Specified

Originator:designatednerd
Number:rdar://47113341 Date Originated:08-Jan-2019 02:23 PM
Status:Closed Resolved:Duplicate
Product:Developer Tools Product Version:Xcode 10.1 (10B61)
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
Using named colors in an asset catalog causes the IBDesignables agent to crash and leave IB in an unusable state if you attempt to access and force-unwrap those colors in `prepareForInterfaceBuilder`. 

If your asset catalog is in the `main` bundle, passing `Bundle.main` is still not sufficient, you have to pass something like `Bundle(for: AppDelegate.self)` (or some other class in the main bundle) for the agent to stop crashing. 

Steps to Reproduce:
1. Add named colors to Asset Catalog in main bundle
2. Attempt to access said colors in `prepareForInterfaceBuilder` without specifying bundle
3. IBDesignables agent crashes, IB turns into Big Pile Of Boxes Of Sadness
4. Attempt to use main bundle
5. Pile of Boxes of Sadness Remains

Expected Results:
Named colors in the asset catalog can be referenced from `IBDesignable` without having to pass in a bundle if they’re in the main bundle. 

Actual Results:
Crashola.

Version:
Xcode 10.1 (10B61)

Notes:
Again, this *can* be worked around by passing in `Bundle(for: AppDelegate.self)` but that’s really not obvious at all. See `Color.swift` for the 3 options I tried and how they worked.

This is all only something you can figure out if you dive through crash reports in Console. There is no indication of where the issue is directly within Xcode when the IBDesignables agent crashes.

Comments

Closed as a dupe of 28676479, which is still open, on 14 January 2019

By designatednerd at Jan. 14, 2019, 9:46 a.m. (reply...)

Attached project is available at https://github.com/designatednerd/FileARadar/tree/master/IBDesignablesCrasher

By designatednerd at Jan. 8, 2019, 1:26 p.m. (reply...)

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!