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
Generate empty enum if section contains no constants #14
Comments
Can you provide an example demonstrating what you expect and what you are actually getting? |
I have a helper that creates ViewControllers from extension UIStoryboard {
class func main() -> UIStoryboard {
return UIStoryboard(name: "Main", bundle: nil)
}
public func viewControllerWithID(identifier: ViewControllerStoryboardIdentifier) -> UIViewController {
return self.instantiateViewControllerWithIdentifier(identifier.rawValue) as UIViewController
}
} Starting with an empty project and the above helper, use the SBConstants CLI to create an initial constants file. Results: Expected: public enum ViewControllerStoryboardIdentifier {} However, empty enums trigger a compiler error, so we would need to come up with a default value for empty enums. // Something like this, not sure...
public enum ViewControllerStoryboardIdentifier: String {
case _unused = "_"
} |
This doesn't seem like a very generic use case to me. I'd be interested if anyone else has any opinions on this but I don't think the tool should generate an enum with placeholder values if nothing is found. |
Hm, I know what you mean. I kinda pollutes the file with unnecessary boilerplate. I generally don't have a strong opinion on this, just wanted to start a discussion to see if anyone else has a similar "problem". |
Hey @aschuch doesn't look like anyone has picked up on this conversation. I'm going to close the issue but if you have any more thoughts feel free to reopen. |
I am using some helper methods and swift extensions to work with the enums provided by SBConstants.
However, if e.g. there is no segue identifier setup in the storyboard, the generated SBConstants file omits the enum altogether.
This of course breaks any custom code that directly references the enums, e.g.
SegueIdentifier
.I think it would be fine to output the empty enum in case there are no constants defined.
Any opinions?
The text was updated successfully, but these errors were encountered: