You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
The text was updated successfully, but these errors were encountered:
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
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 Swiftenum
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 ofParentChild
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
The text was updated successfully, but these errors were encountered: