Packge + import or Internal + @testable import?

We don’t recommend adding package access level solely for testing purposes. However, if package is already extensively used in your production code, it would be a better alternative to @testable, as we've been discouraging the use of that annotation due to unmaintained bugs, with plans to eventually deprecate it. That said, if your project contains few package symbols or needs access to internal symbols for testing, @testable can still be an option.

For the default SPM test template, though, it might be worth moving away from @testable since package access control already grants visibility to symbols within the same package across modules, thus the need for @testable becomes redundant. cc @Max_Desiatov

2 Likes