4

I'm currently converting some of my code to compile in Xcode 9 and stumbled over some different behaviour which forces me to use some code only in Xcode 9 and some only in Xcode 8. Is there some kind of ifdef so I can redirect code based on the Xcode version used?

Any help appreciated. Thanks!

Mike Nathas
  • 1,247
  • 2
  • 11
  • 29
  • Why work with Xcode version? It seems like the better thing to check is either (a) Which version of Swift you are building against or (b) which OS version is being run. –  Sep 04 '17 at 19:27

1 Answers1

5

There are no conditional compilation preprocessor macros for Xcode versioning. Currently, this is the best you can do:

#if swift(>=3.2)
    // Xcode 9 
#else
    // Xcode 8
#endif

Since Swift 3.2 is available only via Xcode 9 or higher, this should serve your practical needs.

If you have discovered an Xcode-related bug, file it at Apple's Bug Reporter website here.

Vatsal Manot
  • 17,695
  • 9
  • 44
  • 80