Nested Swift classes fail to link for Objective-C

Originator:robnapier
Number:rdar://26881987 Date Originated:19-Jun-2016 12:00 PM
Status:Open Resolved:
Product:Xcode Product Version:8 beta
Classification: Reproducible:
 
The following Swift 2.2 code compiles under Swift 3, but will not link if Objective-C code attempts to reference it from another module:

import Foundation
public final class RNCryptor: NSObject {
    @objc(RNEncryptor) public final class Encryptor: NSObject {}
}

...

    [RNEncryptor new];

This compiles, but fails to link, generating the error:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_RNEncryptor", referenced from:
      objc-class-ref in ObjCTests.o

Note that this symbol is missing, but the metaclass is available:

$ nm TestImport | grep RNEncryptor
00000000000022d0 D _OBJC_METACLASS_$_RNEncryptor

When built using Xcode 7.3, both are included:

$ nm TestImport | grep RNEncryptor
00000000000022c0 S _OBJC_CLASS_$_RNEncryptor
0000000000002348 D _OBJC_METACLASS_$_RNEncryptor

Steps to Reproduce:
Create Swift module that exposes nested class to ObjC.
Create test case in ObjC that references that symbol
Link


Expected Results:
Should build, link, and execute.

Actual Results:
Returns undefined symbols

Version:
Version 8.0 beta (8S128d)
OS X 10.11.5 (15F34)

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!