0

Can XCode check for the code compatibility against a specific OS X version? or an external tool?

I have a project that's using a function exists at 10.9 and newer, though I set xcode deployment target to 10.7, it builds without errors but when trying to run the application on 10.8, it doesn't work!!

how can I get functions minimum OS version required?

1 Answer 1

0

Xcode does not provide a tool to check whether a method is available for the deployment target. But if you know that some method is only available from a specific version you can check whether the method is available:

if ([self respondsToSelector:@selector(newMethodNotAlwaysAvailable:withParameters:)]) {
    [self newMethodNotAlwaysAvailable:@"1" withParameters:YES];
}
else {
    // Call some other method to just don't do anything.
}

You can also do ut for classes:

if ([SomeNewClass Class] ) {
    // Class is available and you can use it
}
3
  • yes, it's a good way to check at runtime, but I want to check at build time. why xcode build a code that can't run on 10.7 though the build target is 10.7? I need something like a tool that will iterate over all the project's functions and tell me that the minimum required version is X
    – AMTourky
    Nov 13, 2014 at 11:09
  • 2
    Request for tool, libraries are offtopic for Stackoverflow, but there is such a tool: Deploymate for Xcode
    – rckoenes
    Nov 13, 2014 at 11:10
  • that's exactly what I was looking for, and sorry for the offtopic post, I didn't know about it
    – AMTourky
    Nov 13, 2014 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.