Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Condition #if DEBUG else if PRODUCTION not working in Swift

Tags:

ios

swift

I am trying to use different environments for my application but facing issues doing it. It's not the case that debug is not working the case is none of the variables are working.

I am attaching a screenshot which will make it easier to understand what is happening.

I am not able to access any of the environments.

I ran this code in viewDidLoad of initial view controller of my application and last else condition gets executed.

#if DEBUG
    print("Environment is debug")
    #elseif debug
    print("Environment is debug")
    #elseif Debug
    print("Environment is Debug")
    #elseif RELEASE
    print("Release")
    #elseif PRODUCTION
    print("Environment is production")
    #elseif PROD
    print("Environment is PROD")
    #else
    print("Environment is can't find")
#endif

io

Adding few more images for better clarity regarding schemes and Xcode settings.

enter image description here

enter image description here

like image 888
user3745635 Avatar asked Nov 15 '19 11:11

user3745635


1 Answers

In my case the issue was solved by adding DEBUG as the debug Active Compilation Condition. I know it's already specified when you create a new project, but I don't remember if me or another team's member removed it (and why!). So I decided to put it here just in case someone else is facing the same scenario

DEBUG specification in Active Compilation Conditions

like image 107
mauricioconde Avatar answered Sep 18 '22 20:09

mauricioconde