Setting an IBInspectable Int? value causes the custom view to crash (tested w/Swift)

Originator:joaquimlobosilva
Number:rdar://17218924 Date Originated:08-Jun-2014 01:00 AM
Status:Duplicate of 17218500 Resolved:
Product:Developer Tools Product Version:6.0
Classification:No Value Reproducible:Yes
 
Summary:
When a custom @IBDesignable swift class gets a new @IBInspectable Int property, and whenever I try to set its value in the Xcode Inspector on the Storyboard, the IB Cocoa Touch Tool reports a crash, and the application crashes as well (EXC_BAD_ACCESS, code 2, address 0x0) with a peculiar NSKeyValueIvarSetter stack trace (screenshot attached), with no additional console information printed out.

This seems to happen regardless of the complexity of the custom view itself; simply adding a property of type Int and then setting its value in the Storyboard seems to cause the issue.

Steps to Reproduce:
1. Create a new Xcode project (View-based iOS application, with the language set to Swift—I did not test this in an Objective-C-only project)
2. Add a Cocoa Touch Framework target to the project, embedding it in the Application as well.
3. In the new Framework, create a new Swift Cocoa Touch subclass of UIView (TestView), and mark it as @IBDesignable.
4. Go to the Storyboard (Main.storyboard), and add a View with the same class type as the subclass that has just been created onto the main view of the application.
5. Going back to the TestView.swift in the Framework group, add an @IBInspectable var number: Int?
6. Going back to the Storyboard, setting this value on the inspector should cause the Interface Builder tool to report a crash. The application itself also crashes when run on the simulator.

Expected Results:
The inspectable property should be set with no complaints from the inspector, and the app should run.

Actual Results:
Interface Builder reports a crash and therefore the view is no longer updated live; running the app on the simulator also crashes the app.

Version:
Xcode Version 6.0 (6A215l), Mac OS X 10.9.3 (13D65)

Configuration:
I have only been able to test this on one machine—a Retina MacBook Pro (Late 2013, 15", high-end stock model) running OS X 10.9.3.

Attachments:
'StackTrace.png' and 'IBComplain.png' were successfully uploaded.

Comments

I've just realised that this only applies to optional values. Removing the optional flag solves this problem. Apologies if this is a result of my misunderstanding of how Swift variables are to be used within Xcode.

By joaquimlobosilva at June 8, 2014, 12:06 a.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!