Hi,
Thanks for SwiftGen, I love using it! I will demonstrate how to use it for strings and images on a meetup in two weeks, hoping to help others to help themselves :)
I recently migrated an old project from Swift 2 and added SwiftGen in the process. While doing so, I commented out all language keys and uncommented them one at a time as they were needed.
While doing so, I noticed that SwiftGen adds all commented out language keys to the enum. However, since they are disabled in the strings file, they have no translation.
Would be nice if disabled language keys would not end up in the enum.
Thanks!
Hi @danielsaidi
Thanks for the feedback!
It's cool to hear that SwiftGen was presented at a meetup! (which one was it btw?)
Which version of SwiftGen were you using? I could totally imagine that bug when we were using RegExes to parse the Localizable.strings file back in 3.x but I have a hard time understanding that such a behavior could appear in 4.x where we switched to PLIST parsing instead, fixing some risks like this one in the process…
I'm on my phone right now so can't test it, could you confirm that this issue is in fact already fixed in the latest SwiftGen 4?
Hi again!
I can confirm that I was running SwiftGen 3 on the computer on which I had this problem. I upgraded both the pod and the global script to v4 and now it works. Thanks! :)
I will present SwiftGen as part of a multi-lightning talk session at a regular Stockholm meetup group for iOS developers. Using SwiftGen for strings and images are such immediate improvement and so quick and easy to demonstrate.
Do you have any other parts of SwiftGen that you think I should demonstrate as well?
/Daniel
If you use storyboards, you should definitely try to integrate that generator in your talk. It avoids the whole string based matching during prepareForSegue for example.
For example, in one of my prepareForSegue calls, I do this:
if let identifier = segue.identifier {
switch StoryboardSegue.Stock(rawValue: identifier) {
case .details?:
\\ pass along car object and other information to the details controller
default:
break
}
}
In another project, to instantiate a view controller (and directly have the correct type):
// load user info registration step
let vc = StoryboardScene.Registration.instantiateInfo()
vc.someProperty = "..."
vc.someOtherProperty = 1234
pushViewController(vc, animated: false)
Fonts are really quick and easy to demonstrate as well: if your prepared sample project has custom fonts added in the project and listed in the Info.plist (as usual for custom fonts), then it doesn't take much to add the swiftgen fonts command line to your build phase during the talk and show the generated enum and what it looks like at call site 😉
_I'm gonna close this issue as the original bug reported here is indeed solved, so that other people don't think it's still a bug. But feel free to continue the conversation about the lightning talk here even once the issue is closed!_
Amazing stuff - thank you so much! :D
Also don't hesitate to use the playground already provided in the SwiftGen repository as a support for your talk, it might help you show your audience very quickly the various stuff SwiftGen can do and their advantages.