Xcode 6.3.1: Name of Swift class when exposed to Objective-C does not respect @objc(...) renaming
| Originator: | sascha | ||
| Number: | rdar://20649176 | Date Originated: | 04/22/2015 |
| Status: | Duplicate of 17469485 (Open) | Resolved: | No |
| Product: | Developer Tools | Product Version: | Xcode 6.3.1 (6D1002) |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
When exposing a Swift class to Objective-C with another name by using the @objc(...) prefix, that name is not respected by Objective-C. Instead Objective-C uses the same name for the class as Swift.
Steps to Reproduce:
1. Create a class in Swift and give it another name when exposed to Objective-C like this: @objc(SMPLSwiftViewController) class SwiftViewController: UIViewController { ... }
2. Import the automatically generated Swift Header in an Objective-C file (e.g. "#import SampleApplication-Swift.h")
3. Try to use the Swift class in the Objective-C file by referring to it with its Objective-C name ("SMPLSwiftViewController")
Expected Results:
The Swift class is recognized by its Objective-C name.
Actual Results:
Xcode prints an error saying "Unknown receiver 'SMPLSwiftViewController'; did you mean 'SwiftViewController'?"
Regression:
I can verify that this problem exists at least since Xcode 6.3 beta 3. http://stackoverflow.com/questions/26132823/name-of-swift-class-when-exposed-to-objective-c-code-does-not-respect-the-objc suggests that it exists since Xcode 6.0.1. The problem also exists when importing the Swift code as a dynamic framework.
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!