Reputation: 77621
I'm using swiftgen to generate some enums for my iOS app but the strings that we use have words in them like... "something_string_something" or "something_float_something".
This means that when the enums are generated it creates...
public enum String {
...
}
public enum Float {
...
}
And then the corresponding functions that use variables like...
public enum Something {
public static func name(_ p1: Int) -> String {}
}
Then have a compile error because the compiler thinks that the String
in the return type is actually the public enum String
and not just standard Swift String
.
Is it possible to define alternative keys in this case? Like if I wanted it to out using public enum Strng
and public enum Flt
instead to avoid the collision?
Obviously, if I could change the originating strings I would but they are not so easy to change in a mature project like the one I'm working on.
Upvotes: -1
Views: 557
Reputation: 77621
Following @Larme's advice I created my own custom template using this documentation... https://github.com/SwiftGen/SwiftGen/blob/stable/Documentation/Articles/Creating-custom-templates.md
I copied the pre-made template I wanted to use and then changed it in a few places to add Swift.
to several of the types.
So now instead of using String
, Int
, Float
, etc... it uses Swift.String
, Swift.Int
, Swift.Float
and generates and builds with no issues.
Thanks @Larme 👍🏻
Upvotes: 0