SwiftGen / SwiftGen

The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!
MIT License
9.23k stars 732 forks source link

Swiftgen keeps resurrecting deleted classes and storyboard #281

Closed ayrtonsoftware closed 7 years ago

ayrtonsoftware commented 7 years ago

I am stuck with a build compile that fails on a class not found error. Turns out, I removed this class from the project, yet swiftgen seems to find it someplace. Not sure where. This makes the tool useless as I am now unable to get any clean compiles. Performing a clean before a rebuild does not help.

djbe commented 7 years ago

Hi,

Can you check if the class files (or storyboard files) are still on your filesystem? Could you make sure that your swiftgen build step is running correctly? You can always try to run it manually.

You can also do a project wide search (using Xcode) for the class name. It'll also search through storyboards, if you for example are still using the class in another storyboard file.

AliSoftware commented 7 years ago

Hi @ayrtonsoftware

As @djbe said I'd encourage you to check your filesystem: swiftgen scan files on disk and doesn't check wether or not those files are actually part of your Xcode project, so it's very possible that you deleted the files from Xcode but not in the Finder.

Also could you share the command you're using to generate the files, is it only happening for the swiftgen storyboards subcommand? Maybe you still have one storyboard that references that class for example a scene in one of your storyboards that is marked in interface builder as being of type MyCustomViewController even though you deleted that class (and in that case even if you didn't use swiftgen you'd get into trouble or at least have some logs at runtime when trying to instanciate that storyboard scene because you'd still reference that old class in IB, so at least with SwiftGen those kind of mistakes are detected at compile time instead of crashing at runtime 😉)

Those are the two most likely reasons I see explaining the situation you have.

ayrtonsoftware commented 7 years ago

This is not a nice behavior for SwiftGen. You have the list of files in the project, it should be used. I had removed the storyboard but did not delete it. It really made SwiftGen look bad.....

AliSoftware commented 7 years ago

Feel free to submit a PR to change that behavior, but parsing the xcodeproj and determining which files are in which target and knowing for which target (as nowadays Xcode projects with more than one target is very common) you want that generated — while most of the time it should be reusable across targets) is really complicated (especially given the format of a xcodeproj file)

But I'd love that new behavior that you propose, that would indeed be awesome if SwiftGen would be able to rely on the content on the Xcods project, so don't hesitate to submit a PR to help us support that!

I'm gonna close this issue now as what you had was the expected behavior for the way SwiftGen works today. We could discuss adding the implementation of the new feature of parsing and interpreting the xcodeproj and xcworkspace file in a new issue of you want.