Skip to content

[SR-5415] Swift extension with static let accessed from objc triggers "incompatible Objective-C category definitions" linker warning #47989

@bobergj

Description

@bobergj
Previous ID SR-5415
Radar None
Original Reporter @bobergj
Type Bug
Status Closed
Resolution Invalid
Environment

Xcode Version 8.3.3 (8E3004b), Swift 3
Xcode 9 beta 2, Swift 4

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

md5: ffa2458039f895089dd9ab0b8bf7cfac

Issue Description:

Sometimes an extension on UIColor:

extension UIColor {
    static let someColor = UIColor.darkGray
}

accessed from objc:

#import "AppTargetName-Swift.h"
...
    [UIColor someColor];

Triggers a linker warning such as:

ld: warning: Some object files have incompatible Objective-C category definitions. Some category metadata may be lost. All files containing Objective-C categories should be built using the same compiler.

In this case, all code is definitely built with the same compiler, it's all built at the same time.
Both the Swift module and objective-c module is part of the application target

We can consistently reproduce this issue (on different machines) in a particular project, but in a new minimal project with only the UIColor extension and the obj-c access it doesn't occur. There seems to be another factor involved that triggers the warning.
We cannot share the code of our project, put perhaps there is a linker option to enable more verbose output related to the warning?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions