0

Is there a precompiler directive that checks if a framework is linked in an Obj-C/Cocoa project?

For example, I have a class of useful categories with some MapKit categories. However, if MapKit is not linked to the framework, then those categories will not compile.

Is there anything like:

#ifdef MAPKIT
....
// Only compiles if MapKit framework is linked to the current project
....
#endif
Daniel Amitay
  • 6,677
  • 7
  • 36
  • 43
Martin
  • 11,881
  • 6
  • 64
  • 110

2 Answers2

2

MapKit would also require a header file. MKFoundation.h defines MK_EXTERN. You could check for that.

#ifdef MK_EXTERN

#endif

estobbart
  • 1,137
  • 12
  • 28
  • there's no reason MapKit's headers would need to be precompiled. it's actually a bad idea to add the world to the PCH. – justin Oct 18 '12 at 21:29
  • but defines like these may help you to fire up warning that you forgot to include that particular framework instead of sometimes confusing linking error which you need to google to find out what's missing from project – PetrV Oct 24 '12 at 09:06
1

No. Preprocessing and compilation happens at one build phase -- Linking is a separate phase.

Xcode does not provide an easy way for you to access/enumerate the build settings related to linking in a source file.

justin
  • 104,054
  • 14
  • 179
  • 226