2

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

Shiva
  • 545
  • 1
  • 10
  • 41

2 Answers2

4

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.

Durai Amuthan.H
  • 31,670
  • 10
  • 160
  • 241
1

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

k.zoli
  • 41
  • 8