Can the Xcode linker remove unused code when you import a Swift package?

Viewed 242

Let's say you import a Swift package from which you only need a tiny piece (for example a single method from the Swift Algorithms package)

It seems the linker doesn't optimize away all the other methods - for a simple example project only using chunks(ofCount:) from the Swift Algorithms package the binary size grew from 193 KB to 3,9 MB. So it seems getting only a tiny piece of a large package is a bad idea if you care about app binary size.

Is there a better way to reduce the resulting app binary size besides removing the Swift package and copying the actually needed source files to your own project?

0 Answers
Related