Reputation: 21137
I have something like this in my App:
#if PRODUCTION
let code: String? = "1111"
#elseif DEMO
let code: String? = "2222"
#elseif TEST
let code: String? = "3333"
#else
let code: String? = "0000"
#endif
The problem is that at a deployment target, which has the flags DEMO
and TEST
, I get Definition conflicts with previous value
for the lines 4 and 6. How is this possible? isn't #elseif
supposed to be exclusive?
UPDATE
Although it is strange, this works:
let code: String?
#if PRODUCTION
code = "1111"
#elseif DEMO
code = "2222"
#elseif TEST
code = "3333"
#else
code = "0000"
#endif
I also have targets where only TEST
or PRODUCTION
is defined and it worked with the previous code, so I suppose only cases that could possibly be compiled are parsed.
Upvotes: 1
Views: 71
Reputation: 1928
Build Configuration Statement
Each statement in the body of a build configuration statement is parsed even if it’s not complied.
I don't know why Apple parses every statement in the Build Configuration Statement, but they do and I think this causes the problem.
Upvotes: 1