Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only run code if on a certain version of Xcode

Tags:

xcode

ios

swift

I'm making a library that uses the variants variable of AVAsset. That's less important; the significant part is that it has an Xcode 13+ requirement. This library may be used by apps running Xcode 12. Is there a compiler flag that can run code only if on a certain version of Xcode?

Something like how you would do this for a Swift version:

#if swift(>=5.0)
   // code
#else
   // code
#endif

I'd want to do

#if xcode(>=13.0)

   // use variants

#endif
like image 482
Hackerman Avatar asked Nov 23 '25 23:11

Hackerman


1 Answers

I found that #if compiler(>=5.5) works here. Note, this is different than if swift(>=5.5), which will not necessarily work depending on the swift version you have set in your project.

like image 164
Hackerman Avatar answered Nov 26 '25 11:11

Hackerman