Xcode should offer a fixit when you attempt to use a Swift-only member from Objective-C

Number:rdar://41651051 Date Originated:June 29 2018
Status: Resolved:
Product:Developer Tools Product Version:
Classification: Reproducible:
When I forget to annotate a tag a member of a Swift class (or the whole Swift class itself) with @objc, but then I use the member (or the whole Swift class itself) from Objective-C, Xcode only says the member or class doesn't exist. However, Xcode should provide a better suggestion and offer a fixit to tag the related member or class with @objc.


My response to them

That's fine, but if there is no legal Objective-C selector, and you attempt to use a Swift selector, Xcode could at least emit a warning about it.

By heath.borders at July 9, 2018, 2:46 p.m. (reply...)

Apple responded

Engineering has provided the following information regarding this issue:

This is deliberately not implemented. Since Objective-C methods are identified by class and selector, noting that a particular selector comes from Swift could interfere with an Objective-C category elsewhere in the project that tried to provide that selector. It is unusual but permitted for Swift and Objective-C to define methods that would have the same selector, but to then not expose the Swift method to the Objective-C runtime.

By heath.borders at July 9, 2018, 2:45 p.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!