Last active
March 12, 2024 13:57
-
-
Save steipete/6526860 to your computer and use it in GitHub Desktop.
A simple way to detect at runtime if we're running in UIKit legacy mode or the new "flat" variant. Written for our PDF iOS SDK (http://pspdfkit.com), where the precompiled binary needs to detect at runtime in what variant it's running. Want more stuff like that? Follow me on Twitter: http://twitter.com/steipete
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
// Taken from http://PSPDFKit.com. This snippet is under public domain. | |
#define UIKitVersionNumber_iOS_7_0 0xB57 | |
BOOL PSPDFIsUIKitFlatMode(void) { | |
static BOOL isUIKitFlatMode = NO; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
// We get the modern UIKit if system is running >= iOS 7 and we were linked with >= SDK 7. | |
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) { | |
isUIKitFlatMode = (NSVersionOfLinkTimeLibrary("UIKit") >> 16) >= UIKitVersionNumber_iOS_7_0; | |
} | |
}); | |
return isUIKitFlatMode; | |
} |
iOS 15.0 is 0x13CB
(lldb) p (uint32_t)NSVersionOfLinkTimeLibrary("UIKit") >> 16
(uint32_t) $2 = 5067
iOS 15.2 is 0x1455
(lldb) p (uint32_t)NSVersionOfLinkTimeLibrary("UIKit") >> 16
(uint32_t) $1 = 5205
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For iOS 12 (GM), it seems that casting to unsigned integer is now required:
-> UIKitVersionNumber_iOS_12_0 = 0xEE48