Skip to content

[swift2objc] Using @objc namespacing to replace Wrapper suffix when generating ObjC #2087

@nikeokoronkwo

Description

@nikeokoronkwo

One of the major reasons the Wrapper suffix was implemented is so that when generating the given files, the names wouldn't clash. However, this would no longer be necessary when going from Swift to Objective C.
Therefore, this issue proposes making use of @objc namespacing so that the names can be reverted back to their original names when exporting to Objective-C.

That is, a declaration MyDecl converted to MyDeclWrapper can have @objc(MyDecl):

// a.swift
public struct MyDecl {
// properties and methods...
}


// b.swift
@objc(MyDecl) public class MyDeclWrapper: NSObject {
  // properties and methods...
}

In Objective-C, the declaration will be named MyDecl (no name collisions, since C-family of languages use file-based imports)

SWIFT_CLASS_NAMED("ObjCTestBench")
@interface MyDecl: NSObject
// properties and methods
@end

If agreed upon, the generation logic would be refactored to using @objc(<original-name>) rather than just @objc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions