IBInspectable doesn't support enum ¯\_(ツ)_/¯

Originator:Dani.Arnaout
Number:rdar://32443199 Date Originated:May 27 2017, 11:05 AM
Status:Open Resolved:No
Product:Xcode Product Version:8.3.1
Classification:Suggestion Reproducible:Yes
 
Summary:
It's well known that IBInspectable only supports the following types:
Int
CGFloat
Double
String
Bool
CGPoint
CGSize
CGRect
UIColor
UIImage

It would be awesome if we can have support for enum as well :/ 
This is important as the only possible workarounds are messy and bad, really bad. (Ex: using NSInteger or NSString)

Steps to Reproduce:
1- Create a class called "CustomLabel"

2- Create an enum called "DateFormat" and set three options (Short, Medium, Full)
enum DateFormat: Int {
 case Short // 05/27/2017
 case Medium // May 27,2017
 case Full // May 27, 2017 9:10 AM
}

3- Create a var called format, a DateFromat enum with IBInspectable capability
 class CustomLabel: UILabel {
   @IBInspectable
   var format: DateFormat = .Short {
     didSet {
       // update label
     }
   }
}

4- Go to your storyboard
5- Drag a UILabel to your view controller
6- Set its class to CustomLabel from the attribute inspector
7- Look for the new attribute "format" in the label's attribute inspector

Expected Results:
See an attribute called "format" that is an enum with three options (Short, Medium, Full)

Observed Results:
No new attributes for CustomLabel were added. Enums are not yet supported as IBInspectable

Version:
Xcode 8.3.1 (8E1000a)
macOS 10.12.5 (16F73)

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!