OtoLeo
OtoLeo

Reputation: 363

Conditional compilation on iOS

I have an iOS project that has two targets. The first one is intended to be used as the normal application, while the second one will include third party classes to extend functionality.
I wish to be able to compile both of them within the same Xcode project, but I need to exclude third party classes in the first target in order to avoid paying licenses that we won't use.

I've considered doing something like this:

#ifdef THIRD_PARTY
  NSLog(@"Third party enabled");
#else
  NSLog(@"Third party disabled");
#endif

But I'd need to define THIRD_PARTY in a building settings file, and I couldn't do so.

What do you think?

Upvotes: 0

Views: 359

Answers (1)

CSmith
CSmith

Reputation: 13458

Create multiple TARGETS in your XCode project. You can then add the 3rd party classes to one of the targets, and exclude from the other.

Perhaps I'm misunderstanding as I see you've already got two targets ... you can either do the conditional compile thing in your code where needed, adding the #define to one of the targets build settings, or you could create a stub class that has same interface as your 3rd party classes, but all empty implementation.

Upvotes: 1

Related Questions