Detecting an Archive vs. Development build

I have a 3rd party library that requires a licensing key. I have two: I have a development key that will not work with IPAs and is used to build to a phone in development. And I have a Production key which will workonly from an IPA/Archive build but not directly on a phone.

Is there a compiler directive that can tell me if I am building to an Archive/IPA or developmently to a phone?

Currently I have resorted to creating separate project targets to achieve this task, but it is clumsy and inelegant (and prone to error).

I am using XCode13 & Swift 5.5

Thanks-in-advance, Tom

Not sure if this is the best solution to achieve what you want, but I would add another Configuration for Archive.

You can choose the Build Configuration in the Scheme editor of Archive, and you can put a Custom Flag in the Build Settings for Archive configuration.

Detecting an Archive vs. Development build
 
 
Q