Will an unused module be ignored by the compiler

May sound silly, but just wanted to make sure that if I import /declare a module in Swift, say:

Code Block
#import GameplayKit

And use none of its definitions, will the Xcode compiler not include it in the build?
Answered by Claude31 in 642560022
Yes, it is ignored.

Interesting reference here:
https ://thoughtbot. com/blog/swift-imports

As far as performance and binary size goes, any unused symbols are already optimized out of the final binary by the Swift compiler. If there’s no reference to it at compile time then it’s removed, meaning that importing a framework but not using particular parts of it shouldn’t have any negative implications.


Accepted Answer
Yes, it is ignored.

Interesting reference here:
https ://thoughtbot. com/blog/swift-imports

As far as performance and binary size goes, any unused symbols are already optimized out of the final binary by the Swift compiler. If there’s no reference to it at compile time then it’s removed, meaning that importing a framework but not using particular parts of it shouldn’t have any negative implications.


Will an unused module be ignored by the compiler
 
 
Q