Swift Extensions and Information Hiding

Andrew Bancroft tested and analyzed the behavior of extensions in Swift. While his findings aren’t utterly surprising, having them summed up in this nicely done article certainly helps.

In a nutshell:

This has consequences for your tests: they reside in a separate module, so they can only access public members of your classes.

If you extend classes from static libraries, the same holds true. Different module, only public accessors.

Browse the blog archive