App trying to use compilation condition defined in SPM module

I'm defining a compilation condition in a SPM module that is being used by my iOS app. I'd like to be able to use the same compilation condition in my app code to determine behavior, but the condition doesn't seem to be getting set within my app. The condition is working as expected within the SPM module, just not in the iOS app that is importing the module.

Package.swift excerpt

target(..., 
swiftSettings: [.define("CONDITION", .when(configuration: .debug))]
)

SPM Module

#if CONDITION
// Compiled and executes as expected
#endif

App

#if CONDITION
// Never compiled / triggered
#endif 

Conditionals you set in your package don’t ‘flow up’ to Xcode. If you want the conditional set there, you’ll have to define it in Xcode as well. See this build setting.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

App trying to use compilation condition defined in SPM module
 
 
Q