Shiva
Shiva

Reputation: 585

How do I pass preprocessor macro name in xcode build command?

I am doing CI build on azure devops. I am wondering how to pass pre-processor macro value so that I can make different flavours of build.

AFAIK if we can set preprocessor macro in xcode build then we can do it on azure devops as well.

Any helpful pointer is welcome

Upvotes: 2

Views: 1984

Answers (2)

Durai Amuthan.H
Durai Amuthan.H

Reputation: 32320

Approach 1: By the means of GCC_PREPROCESSOR_DEFINITIONS

You have to make use of GCC_PREPROCESSOR_DEFINITIONS on xcodebuild command line.

Here is a sample macro in your code

#ifdef Flavour1 

NSLog(@"This is flavour 1"); 

#endif

and Here is how you pass the macro through command line

xcodebuild -verbose -scheme "YourAppScheme" GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS Flavour1=1'

Approach 2: By the means of separate xcode Scheme

Have a scheme and it's respective target for each flavour. so that it can have different App name,version number,signers etc if required and you can have macro injected in preprocessor definition of build settings in target.

All you have to do is just pass the right scheme in xcodebuild command and that's you sorted

P.S:-

I personally prefer Approach 2 because it's easy to customise without worrying much about xcodebuild command line parameters.

Upvotes: 4

k.zoli
k.zoli

Reputation: 39

You can create a ruby script which can setup the project. Xcodeproj is a powerful tool to modify Xcode projects.

https://github.com/CocoaPods/Xcodeproj

Upvotes: 0

Related Questions