]>
Commit | Line | Data |
---|---|---|
19fa75a9 A |
1 | /* |
2 | * Copyright (c) 2019 Apple Inc. All rights reserved. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | #if !defined(__i386__) | |
18 | #include "bundle_utilities.h" | |
19 | ||
20 | #import <CoreServices/CoreServicesPriv.h> | |
21 | #import <CoreUtils/SoftLinking.h> | |
22 | ||
23 | SOFT_LINK_FRAMEWORK_EX(Frameworks, CoreServices); | |
24 | SOFT_LINK_CLASS_EX(CoreServices, LSBundleRecord); | |
25 | #define LSBundleRecordSoft getLSBundleRecordClass() | |
26 | ||
27 | SOFT_LINK_FRAMEWORK_EX(Frameworks, Foundation); | |
28 | SOFT_LINK_CLASS_EX(Foundation, NSString); | |
29 | #define NSStringSoft getNSStringClass() | |
30 | ||
31 | bool bundle_sdk_is_ios14_or_later(void) | |
32 | { | |
33 | #if TARGET_OS_OSX | |
34 | #define MIN_SDK_VERSION "10.16" | |
35 | #elif TARGET_OS_WATCH | |
36 | #define MIN_SDK_VERSION "7.0" | |
37 | #else | |
38 | #define MIN_SDK_VERSION "14.0" | |
39 | #endif | |
40 | BOOL result = NO; | |
41 | ||
42 | if (LSBundleRecordSoft && NSStringSoft) { | |
43 | @autoreleasepool { | |
44 | id rec = [LSBundleRecordSoft bundleRecordForCurrentProcess]; | |
45 | if (rec) { | |
46 | NSString * min_vers = [NSStringSoft stringWithUTF8String:MIN_SDK_VERSION]; | |
47 | NSComparisonResult compare_result = [[rec SDKVersion] compare:min_vers options:NSNumericSearch]; | |
48 | result = ((compare_result == NSOrderedSame) || (compare_result == NSOrderedDescending)); | |
49 | } | |
50 | } | |
51 | } | |
52 | ||
53 | return (result != NO); | |
54 | } | |
55 | #endif |