I have multiple target created in my project. Now I'm planing to add a string UUID
to all the targets GCC_PREPROCESSOR_DEFINITIONS aka preprocessor macro.
I'll add this to Alpha, Beta, Lite & Prod. And based on the UUID string I can know about which variant is running and use corresponding configurations to handle dynamically
Lets say for Target1 I want to add UUID="<UUID for Target1>"
and I'll add 4 uuids in each target.
Now I have two challenges:
For the 1st option, I've searched over the internet but found solution for adding int values and while retrieving the value is being checked using if elif and else in both swift & objective-C
But I want to add a string value
and while retrieving I want to assign that value to my local swift variable and use that uuid.
How can I retrieve string value from Preprocessor macro to Swift variable?
May be a basic question, but I didn't find anything for this.
It is possible, but we need the help of OC since Swift's Marco is weak.
S_UUID="2EBEA32B-60AE-48FA-90E1-686DD83512DE"
I added an S_
prefix to prevent the symbol from conflicting with system symbols.
//turns x into a string literal
#define STRINGIZE(x) #x
//uses STRINGIZE(x) to turn the value of x into a string.
#define STRINGIZE_VALUE_OF(x) STRINGIZE(x)
NSString *uuid = @STRINGIZE_VALUE_OF(S_UUID);
I have created the POC project here. It also has the code to use the retrieved UUID in Swift.