Namespacing

The WWDC talks you mentioned also talk about the cost of Obj-C vs. Swift frameworks. One of their biggest recommendations was "use Swift" to improve launch times.

Indeed I checked they advise to use more Swift to reduce Initializer time but the dylib loading time is not impacted. However I just gave a little try to Swift Package Manager and it links the frameworks statically in priority so the launch time should not be an issue when using SPM :)

It seems indeed quite hacky to me to use either struct with private init or enum but my biggest issue is that we can't nest protocols in either one of them.

2 Likes

I also agree regarding the hackiness. When I (or my colleagues, or a consultant, or someone joining the project long after I've left it) see an enum, one expects an enumeration with at least one case. Enum-as-a-namespace is an idiom that has to be actively learned, and my experience with Swift is that recurring idioms are encoded into the language itself so that it doesn't have to be recognised by human pattern matching.

3 Likes