I've been converting a large monolithic application to move certain code into packages; mostly this has gone well.
However, one area I am having trouble with is getting various code in my packages to respect an #if DEBUG
section. I use these a lot in the debug builds to run all sorts of other diagnostics, performance and logging that I don't even want compiled for release.
i.e in some library code:
#if DEBUG
extension SomeClass {
public func printTopSecretInternalState {
....
}
}
#endif
and then in the main app:
let someClass = getSomeClass()
#if DEBUG
someClass.printTopSecretInternalState()
#endif
// carry on using someClass
It seemed to me that adding this to my target would do what I want:
swiftSettings: [.define("DEBUG", .when(configuration: .debug))]
But when I built my app in its debug configuration it complained in the app code that SomeClass doesn't have a printTopSecretInternalState
function.
After some experimentation I figured out what was going on, in my Xcode project, the build configurations are not named "Debug" or "Release", but instead we have something similar to these:
If I rename one of the "Dev' configurations to "Debug" then the above #if DEBUG stuff works as expected but that is a pain as:
- I'd need to be constantly renaming one of the Dev configurations to Debug depending on which one I want to debug.
- There are other parts of the build process (i.e scripts) that rely on the configuration name to decide to do (or not do) things.
Is there no way to designate a configuration as being for 'debug' without having to have the explicit "Debug" name??