I have an app that uses TestFlight SDK and other debugging frameworks which I want to remove automatically for App Store release builds.
I created a new "App Store" build configuration, but how can I teach Xcode which frameworks I want to be included with this build? And how can I make the code that uses these frameworks conditional so it is excluded from the App Store release build?
You have three components of the process that work in your favor, to remove extraneous code.
First, you have the preprocessor. If you wrap your TestFlight import and code with #if DEBUG
statements, then you will be fine. The #if
statement is designed so that the preprocessor will strip out extra statements that you don't need. It won't make it to the compiler.
Second, the compiler is there for you. The compiler is smart about stripping dead code from release builds. If you write code and don't use it, it won't make it into the final binary, even if it passes the preprocessor.
Third, if you're really concerned about those frameworks making it into your release builds, you can make an extra target in Xcode, and change the linker options for that target. This isn't necessary, but the option is there for you if you'd like. This is the closest to your "explicit exclusion".
Honestly, though, trust your compiler and linker, unless they give you reason not to.