Skip to content

Commit c6df692

Browse files
authored
fix: accessing Availability.h macros in Swift (Xcode 26 support) (#4013)
* Create AmplifyAvailability shim for Availability.h imports * Update ASFAppInfo to use AmplifyAvailability * Use traditional target instead of systemLibrary with better support for Xcode 15
1 parent 7fa7abd commit c6df692

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/ASF/ASFAppInfo.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8+
import AmplifyAvailability
89
import Foundation
910

1011
struct ASFAppInfo: ASFAppInfoBehavior {
@@ -16,9 +17,9 @@ struct ASFAppInfo: ASFAppInfoBehavior {
1617
var targetSDK: String {
1718
var targetSDK: String = ""
1819
#if os(iOS) || os(watchOS) || os(tvOS)
19-
targetSDK = "\(__IPHONE_OS_VERSION_MIN_REQUIRED)"
20+
targetSDK = "\(getIOSVersionMinRequired())"
2021
#elseif os(macOS)
21-
targetSDK = "\(__MAC_OS_X_VERSION_MIN_REQUIRED)"
22+
targetSDK = "\(getMACOSXVersionMinRequired())"
2223
#else
2324
targetSDK = "Unknown"
2425
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
#include "include/AmplifyAvailability.h"
9+
#include <Availability.h>
10+
11+
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
12+
int getIOSVersionMinRequired(void) {
13+
return __IPHONE_OS_VERSION_MIN_REQUIRED;
14+
}
15+
#endif
16+
17+
#if TARGET_OS_OSX
18+
int getMACOSXVersionMinRequired(void) {
19+
return __MAC_OS_X_VERSION_MIN_REQUIRED;
20+
}
21+
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
#ifndef AmplifyAvailability_h
9+
#define AmplifyAvailability_h
10+
11+
#include <TargetConditionals.h>
12+
13+
#if TARGET_OS_IOS || TARGET_OS_WATCH || TARGET_OS_TV
14+
int getIOSVersionMinRequired(void);
15+
#endif
16+
17+
#if TARGET_OS_OSX
18+
int getMACOSXVersionMinRequired(void);
19+
#endif
20+
21+
#endif /* AmplifyAvailability_h */
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module AmplifyAvailability {
2+
header "include/AmplifyAvailability.h"
3+
export *
4+
}

Package.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ let authTargets: [Target] = [
179179
name: "AWSCognitoAuthPlugin",
180180
dependencies: [
181181
.target(name: "Amplify"),
182+
.target(name: "AmplifyAvailability"),
182183
.target(name: "AmplifySRP"),
183184
.target(name: "AWSPluginsCore"),
184185
.target(name: "InternalAmplifyCredentials"),
@@ -191,6 +192,11 @@ let authTargets: [Target] = [
191192
.copy("Resources/PrivacyInfo.xcprivacy")
192193
]
193194
),
195+
.target(
196+
name: "AmplifyAvailability",
197+
path: "AmplifyPlugins/Auth/Sources/AmplifyAvailability",
198+
publicHeadersPath: "include"
199+
),
194200
.target(
195201
name: "libtommathAmplify",
196202
path: "AmplifyPlugins/Auth/Sources/libtommath",

0 commit comments

Comments
 (0)