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

Strings: Add support to generate Objective-C compatible Strings Swift code #489

Open
lukaskukacka opened this issue Sep 7, 2018 · 1 comment · May be fixed by #490
Open

Strings: Add support to generate Objective-C compatible Strings Swift code #489

lukaskukacka opened this issue Sep 7, 2018 · 1 comment · May be fixed by #490

Comments

@lukaskukacka
Copy link

lukaskukacka commented Sep 7, 2018

I suggest to add a support for generating Objective-C compatible code Swift code for Strings. This would be valuable for mixed Objective-C / Swift projects.

Technical feasibility

To be Objective-C compatible, the template must generate NSObject subclass (instead of Swift enum with proper @objc annotations.

Solving nested classes not being available for Objective-C

Objective-C does not support Swift's nested classes. Only the root class is available in Objective-C by default.
This can be solved by providing custom class name for the nested classes using @objc(ClassName) expression. I suggest using simple namespacing scheme in form of camel-cased chaining of ParentChild class names.

Backwards compatibility

The change would be opt-in only via objcCompatible parameter to template, keeping 100% backwards compatibility with the current version.

Relation to #376

Although this is similar to #376 "Generate ObjC source for .strings files", this suggestion is different. #376 generates Objective-C .h/.m files while this suggestion is to generate Swift code compatible with Objective-C.


I already have the PR ready and will open it as proposal soon. Creating the issue to follow the process and have it as base for discussion.
[EDIT] related PR is #490

lukaskukacka added a commit to lukaskukacka/SwiftGen that referenced this issue Sep 7, 2018
lukaskukacka added a commit to lukaskukacka/SwiftGen that referenced this issue Sep 28, 2018
lukaskukacka added a commit to lukaskukacka/SwiftGen that referenced this issue Sep 28, 2018
@djbe djbe changed the title Add support to generate Objective-C compatible Strings Swift code Strings: Add support to generate Objective-C compatible Strings Swift code Jan 30, 2019
@akankshakitman
Copy link

Is there any update on adding this PR as we have swift and objc code in one project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants