3

The following question shows how to check the iOS version:

How to check iOS version?

But what if I want to import a file only if the version is above a certain value ? I don't know of any macro for checking the iOS version.

Community
  • 1
  • 1
Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190

1 Answers1

0

#import is a compile time step, so you can't wait until runtime to determine if you should import. The best you can do is import everything you might need, and then at runtime determine if you should use it.

Alternatively, you can build multiple apps, one for older versions of iOS and one for newer versions, each with different linker settings. If you want to explicitly target an older version of iOS with a different code base, you can get to that from the build settings of Xcode by selecting the root of the project in the left tree, and then changing Deployment Target under the Deployment Info section.

slf
  • 22,595
  • 11
  • 77
  • 101
  • But can importing an incompatible file cause the app to crash on older versions ? – Rahul Iyer Apr 30 '15 at 04:58
  • @John that depends entirely on what you are importing, I think it is more likely that including an older file using deprecated calls would crash the app on a newer os or produce some undefined behavior, iOS isn't exactly known for it's stellar backward compatibility. – slf Apr 30 '15 at 05:00