diff --git a/methods.py b/methods.py index 97dc5c8c506..c6f1fd8b088 100644 --- a/methods.py +++ b/methods.py @@ -702,6 +702,24 @@ def CommandNoCache(env, target, sources, command, **args): return result +def get_darwin_sdk_version(platform): + sdk_name = "" + if platform == "osx": + sdk_name = "macosx" + elif platform == "iphone": + sdk_name = "iphoneos" + elif platform == "iphonesimulator": + sdk_name = "iphonesimulator" + else: + raise Exception("Invalid platform argument passed to get_darwin_sdk_version") + + try: + return float(decode_utf8(subprocess.check_output(["xcrun", "--sdk", sdk_name, "--show-sdk-version"]).strip())) + except (subprocess.CalledProcessError, OSError): + print("Failed to find SDK version while running xcrun --sdk {} --show-sdk-version.".format(sdk_name)) + raise + + def detect_darwin_sdk_path(platform, env): sdk_name = "" if platform == "osx": diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 5f1625351e4..7bf49fb4843 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -1,6 +1,6 @@ import os import sys -from methods import detect_darwin_sdk_path +from methods import detect_darwin_sdk_path, get_darwin_sdk_version def is_active(): @@ -14,6 +14,9 @@ def get_name(): def can_build(): if sys.platform == "darwin" or ("OSXCROSS_IOS" in os.environ): + if get_darwin_sdk_version("iphone") < 13.0: + print("Detected iOS SDK version older than 13") + return False return True return False