Last active
December 22, 2015 20:29
-
-
Save zwaldowski/6526790 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern uint32_t dyld_get_program_sdk_version() WEAK_IMPORT_ATTRIBUTE; | |
extern BOOL DZApplicationUsesLegacyUI(void) | |
{ | |
static dispatch_once_t onceToken; | |
static BOOL legacyUI = NO; | |
dispatch_once(&onceToken, ^{ | |
uint32_t sdk = __IPHONE_OS_VERSION_MIN_REQUIRED; | |
if (dyld_get_program_sdk_version != NULL) { | |
sdk = dyld_get_program_sdk_version(); | |
} | |
Boolean hasLegacy; | |
// The OS may set these at will | |
Boolean forceLegacy = CFPreferencesGetAppBooleanValue(CFSTR("UIUseLegacyUI"), kCFPreferencesCurrentApplication, &hasLegacy); | |
Boolean requireModern = CFPreferencesGetAppBooleanValue(CFSTR("UIForceModernUI"), kCFPreferencesCurrentApplication, NULL); | |
legacyUI = ((sdk < 0x70000) && (!(hasLegacy && forceLegacy) || requireModern)); | |
}); | |
return legacyUI; | |
} |
Beware: don’t default to __IPHONE_OS_VERSION_MIN_REQUIRED
because
- It’s not the same as the SDK.
- It doesn’t use the same version encoding: 70000 (decimal) vs 0x70000 (hexadecimal).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's my take on it. Simpler, but not 100% sure this will always work. https://gist.github.com/steipete/6526860