I've just started using Swift (long time dev though) and I'm trying to figure out the best path forwards for organising a codebase. From what I've read namespaces don't really exist in Swift and people resort to things like using enums to wrap things up. Has the community reached any concensus on the best approach? The approaches I've seen are
Use enums - main downside appears to be that everything inside an enum must be in the same file, so if you've got multiple classes inside a namespace you're going to end up with an awfully large file.
Use structs - these appear to be more flexible, you can declare them once and then use extensions to add classes/structs etc. in different files. Main downside is that you can create structs which is a bit weird for something that is actually a namespace - could probably live with it.
Use a flat naming structure, instead of
ProjectUser, feels pretty clunky if you had to use those names in code but perhaps aliases would allow to shorten them at the top of a file (not sure whether you can alias all of types/structs/enums)
Use separate projects for each module in your app. It seems a little heavy handed to break out new projects for every module but perhaps this works well in practice?
So what do you use? If you were starting a new project today which approach would you use?