Why does Swift/Objective-C interoperability rename UpperCamelCase methods from Objective-C?

Consider the following Objective-C class:

@interface TDWClass : NSObject
- (void)Method;
@end

If I include this in the bridging header, and try to invoke the Method from Swift its name is changed from the UpperCamelCase to just camelCase:

TDWClass().Method() // error "'Method()' has been renamed to 'method()'"

I agree that UpperCamelCase for method naming is inconsistent, however I can't see why it is crucial to the extent where the generated code mismatch the original name. Are UpperCamelCase names reserved for some API/System methods? Is there a risk of clashing with some other entities names? I can define such a method name manually in Swift just fine, so the compiler definitely can put up with it. Is there a better rationale than just "it doesn't comply naming guidelines"?

Answered by Claude31 in 726258022

Is there a better rationale than just "it doesn't comply naming guidelines"?

I don't think so.

I think that is part of the larger clean up of API definitions, moving away from ObjC to Swift. There are many other such cases.

Accepted Answer

Is there a better rationale than just "it doesn't comply naming guidelines"?

I don't think so.

I think that is part of the larger clean up of API definitions, moving away from ObjC to Swift. There are many other such cases.

Why does Swift/Objective-C interoperability rename UpperCamelCase methods from Objective-C?
 
 
Q