How to make the swift compiler to remove unused code?

I set up a test project in Xcode and created two SPM targets. The first target depends on the second and uses a class from it, but there is also an unused public function in this class. I compiled the project and profiled the binary file's size using bloaty. It shows me that my file (with the class containing the unused public function) SomeClass.swift contributes 708 bytes to the overall size, but after commenting out the unused function, it contributes only 624 bytes.

If I make this unused function internal, SomeClass.swift also contributes 624 bytes.

I concluded that the compiler can omit internal functions because of whole-module optimization and dead code stripping, but it cannot recognize unused public code.

Am I right, and how can I get it to remove public functions?