xCode6 beta3: Swift compiler does not prohibit usage of non KVC compliant class for NIB file Owner

Originator:vladimir.lisnik
Number:rdar://17738661 Date Originated:19-Jul-2014
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification: Reproducible:
 
Summary:
If you try to specify pure Swift class as NIB file owner you will receive a crash at runtime with error similar to following:

[NSObject 0x7bfa0cc0 setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key myView.

Where 'myView' is the name of an outlet that was connected to the owner using IB.

Steps to Reproduce:
1. Create swift class MyViewOwner
2. Create NIB with single UIView
3. Specify MyViewOwner as owner for the NIB created at step 2
4. Connect the view as outlet to the owner
5. Try to load nib in swift code. Code: NSBundle.mainBundle().loadNibNamed("MyView", owner: myViewOwner, options: nil)
6. Compile (no error or warning about fact that MyViewOwner is non KVC compliant class)
7. Execute code by running the app. (runtime crash)

Expected Results:
Error before compilation stating that: MyViewOwner class is not KVC thus cannot be specified as NIB owner.

OR

Does not allow to set MyViewOwner as NIB owner at all. Like xCode does in case when we specify inappropriate string in class field.

Actual Results:
App crashed with error similar to:

[NSObject 0x7bfa0cc0 setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key myView.

Crush happens due to the reason that pure Swift class is not KVC compliant.

Version:
xCode Version 6.0 (6A254o)

Configuration:
If we inherit MyViewOwner from NSObject everything is fine because NSObject class is KVC compliant

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!