Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-6399] Compilation failures on linux when adding @objc annotations to types that bridge to ObjC classes #48949

Closed
swift-ci opened this issue Nov 15, 2017 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6399
Radar None
Original Reporter kevlario (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

When on mac:

Mac OS 10.12.6
Xcode 9.1 with default toolchain

When on linux:

Ubuntu 16.04
Swift 4.0.2

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: e811e3fd4cc1a74a6c66cea39cbebcd9

duplicates:

Issue Description:

If you have some swift code that exports properties or functions to objc using the @objc annotation, and those properties or functions reference types that automatically bridge to foundation object types like NSString/NSDictionary/etc, the code will compile on macOS successfully but will fail to compile on linux.

Some simple example code:

import Foundation
public class Thing: NSObject {
    @objc public init(name: String) {}
}

This compiles just fine on mac, but gives these errors/notes on linux:

error: method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C
    @objc public init(name: String) {}
                 ^
note: Swift structs cannot be represented in Objective-C
    @objc public init(name: String) {}
                            ^~~~~~

The same thing happens for properties where the type is inferred to be something like String. This is problematic since I'd love to be able to run the same library on Linux that we run on iOS, in order to develop integration testing tools that verify that changes to the server do not negatively impact existing customers of our iOS apps. The code in question is compiled in swift 4 mode, which means we need to provide these annotations for the obj-c code in our codebase.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

1 participant