iOS Xcode: Warn about methods not in minimum target SDK iOS Xcode: Warn about methods not in minimum target SDK ios ios

iOS Xcode: Warn about methods not in minimum target SDK


There is unfortunately no standard way of doing this. By setting the target OS to a lower number than the base SDK, Xcode will weakly link the libraries and frameworks. When doing that Xcode will not warn you for using methods that may not be available on the target OS.

You could temporarily set the base SDK lower, but that might not always work. Since you want to ignore most of the errors and warnings produced (because they are only called conditionally in your code path), and many warnings and errors are dependant on other error that you may need to resolve before the compiler will give any meaningful output.

I do not think there exist any static analysis tools for this, neither from Apple nor third party.


After doing some research, reading the Apple Doc about it, and trying a number of things. The solution is downloading an old Xcode DMG from Apple, grab the .pkg file for the same SDK as your deployment target and install it in your version of Xcode. Here's how:

  1. Download older Xcode.dmg from Apple
  2. Open the DMG
  3. In Terminal, go into packages: "cd /Volumes/[DMG]/Packages; open ."
  4. Find the SDK you want, something like iPhoneSDK_4.0.pkg
  5. Install that package, but change the install directory to /Applications/Xcode/Contents/Developer
  6. Restart Xcode if it was open.

Now that you have the same SDK as your deployment target, set your BaseSDK to the same. When you build you'll get warnings about missing methods. Your project may or may not successfully build with an older BaseSDK in a new version of Xcode, but that doesn't matter - you've just found the method calls you need to wrap in a feature check with respondsToSelector:.


As of Xcode 7.3, the compiler can now generate these warnings for you. All you need to do is set the -Wpartial-availability warning flag in the Build Settings, as described in this answer.