Learn how to error out a distribution construct if a secret injection lacking
When secret is not injected correctly, I wish to fail the archive course of (with Swift). It is solely wanted for Distribution builds, as for Debug builds, I wish to construct with out secret injection.
var apiXSecret: String = Constants.Secrets and techniques.apiXSecret
#if DISTRIBUTION
// If secret is not injected, fail the distribution construct
guard !(apiXSecret.isEmpty) else {
#error("API X Secret is nil or empty for Distribution")
return nil
}
#endif
The next 2 choices do not find yourself stopping the construct.
-
#error("API Secret is nil or empty")— does not find yourself in construct failure. -
assert("API Secret is nil or empty")— with assert, detecting this subject can be potential as soon as the check construct is prepared because the app would find yourself crashing for Distribution.
Ideally, I wish to cease the construct course of if the key is not situated throughout compile time.

