Closed aschuch closed 9 years ago
Can you provide an example demonstrating what you expect and what you are actually getting?
I have a helper that creates ViewControllers from ViewControllerStoryboardIdentifier
.
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. Build the project.
Results:
The build fails, because SBConstants did not create a ViewControllerStoryboardIdentifier
enum, simply because there are no view controllers with an identifier setup in the project yet.
Expected:
Ideally, SBConstants creates an empty ViewControllerStoryboardIdentifier
enum per default.
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?