Swift flags not set when building in on Bitrise

In my code I’m using Active Compilation Conditions like this:

var appExecutionEnvironment: AppExecutionEnvironment = {
    #if DEBUG
        return AppExecutionEnvironment.debug
    #if RELEASE
        return AppExecutionEnvironment.release
    #if STAGING
        return AppExecutionEnvironment.staging

The code compiles on local machine, but not on Bitrise. I get this compilation error:
missing return in a closure expected to return 'AppExecutionEnvironment'

It seems that the flags are not set on Bitrise. I have tried using Other Swift Flags instead of Active Compilation Conditions but that didn’t make any difference. Anyone knows how to fix this issue?

Thank you

Fixed. In my local the app target is selected while on bitrise the test target is selected which doesn’t have the right configurations

1 Like

Glad to hear you managed to solve it @snnazihn - just once note re:

The target is selected by the Scheme (+ the action you run) by default; the bitrise step just passes that parameter to Xcode it does not change anything / it works the same locally.

The Xcode steps have an option to overwrite the Configuration if for some reason you need that, but in general you should not as that’s not how it works on your Mac in Xcode.app . In Xcode.app you configure the “Configuration” for the Scheme + the action (test, archive, …)

Xcode.app → Edit Scheme ... :


In this example the Test action uses the Debug configuration, while the Archive action uses Release configuration (this is the default scheme config when you generate an xcode project).

If you have any questions just let us know! :wink: