swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.61k stars 10.37k forks source link

[SR-8351] Class with @objcMembers annotation and a bool property fail with error on non-Apple platforms #50879

Open swift-ci opened 6 years ago

swift-ci commented 6 years ago
Previous ID SR-8351
Radar None
Original Reporter skela (JIRA User)
Type Bug

Attachment: Download

Environment Linux Swift 4.1
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 287e65c4f37603a06f01779cf622035d

relates to:

Issue Description:

It appears that a NSObject subclass with the @objcMembers and a bool property fail to build on Linux. Commenting out the @objcMembers annotation, and it builds fine. Likewise, leaving the @objcMembers annotation on there and changing the bool property to an int property, also compiles fine.

\<unknown>:0: error: could not find Objective-C bridge type for type 'Bool'; did you forget to import Foundation?
\<unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log
\<unknown>:0: note: unable to set up the ObjC bridge!

Is there any way to workaround this? I've tried

#if os(iOS) @objcMembers #endif

without any luck.

belkadan commented 6 years ago

I don't think you're even supposed to use @objcMembers on Linux, but that puts this in the same camp as SR-3332.

swift-ci commented 6 years ago

Comment by Alek Slater (JIRA)

Yeah, I mean I don't need the objc stuff in Linux obviously, but I'm using the same code on iOS as I plan to on Linux.