Skip to content

Commit d6ce11b

Browse files
authored
Merge pull request #285 from IFTTT/feature/xcode13_compat
Fixes compiler errors when compiling against Xcode 13
2 parents 0968217 + 7e22ed0 commit d6ce11b

8 files changed

+356
-292
lines changed

IFTTT SDK.xcodeproj/project.pbxproj

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
B556033B25A851EE00A29A01 /* Localizable_zh-Hant.strings in Resources */ = {isa = PBXBuildFile; fileRef = B556032325A851ED00A29A01 /* Localizable_zh-Hant.strings */; };
5454
B556033C25A851EE00A29A01 /* Localizable_cs.strings in Resources */ = {isa = PBXBuildFile; fileRef = B556032425A851EE00A29A01 /* Localizable_cs.strings */; };
5555
B556033D25A851EE00A29A01 /* Localizable_nl.strings in Resources */ = {isa = PBXBuildFile; fileRef = B556032525A851EE00A29A01 /* Localizable_nl.strings */; };
56+
DE1F036926A8A20A00B6CF1A /* ASWebServiceAuthentication.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F036826A8A20A00B6CF1A /* ASWebServiceAuthentication.swift */; };
57+
DE1F036B26A8A24500B6CF1A /* SFWebServiceAuthentication.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F036A26A8A24500B6CF1A /* SFWebServiceAuthentication.swift */; };
58+
DE1F036D26A8A29800B6CF1A /* SignInWithAppleAuthentication.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F036C26A8A29800B6CF1A /* SignInWithAppleAuthentication.swift */; };
59+
DE1F037226A8AD2600B6CF1A /* AuthenticationSessionPresentationContextProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE1F037126A8AD2600B6CF1A /* AuthenticationSessionPresentationContextProvider.swift */; };
5660
DE25265623D8C49D0019C9CB /* Analytics.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE25265523D8C49D0019C9CB /* Analytics.swift */; };
5761
DE2906D3242BF66E00CC2825 /* Connection+Parsing.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE2906D2242BF66E00CC2825 /* Connection+Parsing.swift */; };
5862
DE2F524A2429404200EF986A /* Connection+Location.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE2F52492429404200EF986A /* Connection+Location.swift */; };
@@ -73,7 +77,7 @@
7377
DE4C5FFA22CFE570009C7AF9 /* EmailValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE4C5FF922CFE570009C7AF9 /* EmailValidator.swift */; };
7478
DE641D88252B7BC900C56FF9 /* ConnectButtonController+Public.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE641D87252B7BC900C56FF9 /* ConnectButtonController+Public.swift */; };
7579
DE7666E723997568005D6DE3 /* ConnectionVerificationSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE7666E623997568005D6DE3 /* ConnectionVerificationSession.swift */; };
76-
DE7666E9239990C5005D6DE3 /* AuthenticationSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE7666E8239990C5005D6DE3 /* AuthenticationSession.swift */; };
80+
DE7666E9239990C5005D6DE3 /* WebServiceAuthentication.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE7666E8239990C5005D6DE3 /* WebServiceAuthentication.swift */; };
7781
DEBC3C8225421D600052A8CB /* ConnectButtonController+Logging.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEBC3C8125421D600052A8CB /* ConnectButtonController+Logging.swift */; };
7882
DEC08FF02429469C007D7039 /* NativeServices.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC08FEF2429469C007D7039 /* NativeServices.swift */; };
7983
DEC08FF2242948C3007D7039 /* Set+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC08FF1242948C3007D7039 /* Set+Helpers.swift */; };
@@ -225,6 +229,10 @@
225229
B556032425A851EE00A29A01 /* Localizable_cs.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = Localizable_cs.strings; path = Resources/Localizable_cs.strings; sourceTree = "<group>"; };
226230
B556032525A851EE00A29A01 /* Localizable_nl.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = Localizable_nl.strings; path = Resources/Localizable_nl.strings; sourceTree = "<group>"; };
227231
DE1712BC2565B295000B13E6 /* RegionEventsRegistryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegionEventsRegistryTests.swift; sourceTree = "<group>"; };
232+
DE1F036826A8A20A00B6CF1A /* ASWebServiceAuthentication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ASWebServiceAuthentication.swift; sourceTree = "<group>"; };
233+
DE1F036A26A8A24500B6CF1A /* SFWebServiceAuthentication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SFWebServiceAuthentication.swift; sourceTree = "<group>"; };
234+
DE1F036C26A8A29800B6CF1A /* SignInWithAppleAuthentication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignInWithAppleAuthentication.swift; sourceTree = "<group>"; };
235+
DE1F037126A8AD2600B6CF1A /* AuthenticationSessionPresentationContextProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticationSessionPresentationContextProvider.swift; sourceTree = "<group>"; };
228236
DE25265523D8C49D0019C9CB /* Analytics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Analytics.swift; sourceTree = "<group>"; };
229237
DE2906D2242BF66E00CC2825 /* Connection+Parsing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Connection+Parsing.swift"; sourceTree = "<group>"; };
230238
DE2F52492429404200EF986A /* Connection+Location.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Connection+Location.swift"; sourceTree = "<group>"; };
@@ -248,7 +256,7 @@
248256
DE4C5FF922CFE570009C7AF9 /* EmailValidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailValidator.swift; sourceTree = "<group>"; };
249257
DE641D87252B7BC900C56FF9 /* ConnectButtonController+Public.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConnectButtonController+Public.swift"; sourceTree = "<group>"; };
250258
DE7666E623997568005D6DE3 /* ConnectionVerificationSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionVerificationSession.swift; sourceTree = "<group>"; };
251-
DE7666E8239990C5005D6DE3 /* AuthenticationSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationSession.swift; sourceTree = "<group>"; };
259+
DE7666E8239990C5005D6DE3 /* WebServiceAuthentication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebServiceAuthentication.swift; sourceTree = "<group>"; };
252260
DEBC3C8125421D600052A8CB /* ConnectButtonController+Logging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConnectButtonController+Logging.swift"; sourceTree = "<group>"; };
253261
DEC08FEF2429469C007D7039 /* NativeServices.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NativeServices.swift; sourceTree = "<group>"; };
254262
DEC08FF1242948C3007D7039 /* Set+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Set+Helpers.swift"; sourceTree = "<group>"; };
@@ -374,6 +382,19 @@
374382
name = Connection;
375383
sourceTree = "<group>";
376384
};
385+
DE1F036E26A8A33F00B6CF1A /* Web Service Authentication */ = {
386+
isa = PBXGroup;
387+
children = (
388+
DE7666E623997568005D6DE3 /* ConnectionVerificationSession.swift */,
389+
DE7666E8239990C5005D6DE3 /* WebServiceAuthentication.swift */,
390+
DE1F036826A8A20A00B6CF1A /* ASWebServiceAuthentication.swift */,
391+
DE1F036A26A8A24500B6CF1A /* SFWebServiceAuthentication.swift */,
392+
DE1F036C26A8A29800B6CF1A /* SignInWithAppleAuthentication.swift */,
393+
DE1F037126A8AD2600B6CF1A /* AuthenticationSessionPresentationContextProvider.swift */,
394+
);
395+
name = "Web Service Authentication";
396+
sourceTree = "<group>";
397+
};
377398
DE3074A523DB505400A3C71F /* Analytics */ = {
378399
isa = PBXGroup;
379400
children = (
@@ -573,6 +594,7 @@
573594
FCF29FC32187B903004B1100 /* Internal */ = {
574595
isa = PBXGroup;
575596
children = (
597+
DE1F036E26A8A33F00B6CF1A /* Web Service Authentication */,
576598
DEC75CB525092B6100F40296 /* Native Services */,
577599
1DFE020C2190E3DB00856ABC /* API.swift */,
578600
DE3074A523DB505400A3C71F /* Analytics */,
@@ -591,8 +613,6 @@
591613
1D7918402227202700429936 /* Reachability.swift */,
592614
FC361B60224D872D0078B153 /* ProgressBarController.swift */,
593615
DE4C5FF922CFE570009C7AF9 /* EmailValidator.swift */,
594-
DE7666E623997568005D6DE3 /* ConnectionVerificationSession.swift */,
595-
DE7666E8239990C5005D6DE3 /* AuthenticationSession.swift */,
596616
DE328DBD243E18BB00603EAC /* Keychain.swift */,
597617
DEBC3C8125421D600052A8CB /* ConnectButtonController+Logging.swift */,
598618
);
@@ -902,7 +922,7 @@
902922
DE4A4C5E243632A7004082BF /* SynchronizationSubscriber.swift in Sources */,
903923
DE328DB4243CBC9700603EAC /* ConnectionsSynchronizer.swift in Sources */,
904924
DE3074A723DB506D00A3C71F /* AnalyticsNetworkController.swift in Sources */,
905-
DE7666E9239990C5005D6DE3 /* AuthenticationSession.swift in Sources */,
925+
DE7666E9239990C5005D6DE3 /* WebServiceAuthentication.swift in Sources */,
906926
1D453EDE2297216A001994FF /* ConnectButton+AnimationState.swift in Sources */,
907927
FC22B19621ACA54A00738023 /* ImageDownloader.swift in Sources */,
908928
FCF29FC52187C7E0004B1100 /* JSON.swift in Sources */,
@@ -917,6 +937,7 @@
917937
1D453EE22297222D001994FF /* ConnectButton+Interaction.swift in Sources */,
918938
1D4B50AC21949223004D1559 /* ConnectionConfiguration.swift in Sources */,
919939
FC22B19A21ACCD9C00738023 /* ConstraintsMaker.swift in Sources */,
940+
DE1F036926A8A20A00B6CF1A /* ASWebServiceAuthentication.swift in Sources */,
920941
DE328DBC243E185800603EAC /* ConnectionsRegistry.swift in Sources */,
921942
1DFE02092190E35300856ABC /* ConnectionRedirectHandler.swift in Sources */,
922943
FC04FE1B21501A8F008AC8A5 /* AboutViewController.swift in Sources */,
@@ -925,12 +946,14 @@
925946
DE328DC2243E1DED00603EAC /* LocationMonitor.swift in Sources */,
926947
DEC75CBD250A73E000F40296 /* RegionEventsRegistry.swift in Sources */,
927948
1D453EE8229723CA001994FF /* ConnectButton+ProgressBar.swift in Sources */,
949+
DE1F036B26A8A24500B6CF1A /* SFWebServiceAuthentication.swift in Sources */,
928950
DE328DC0243E1DC000603EAC /* RegionsMonitor.swift in Sources */,
929951
1D4B50AA2194857A004D1559 /* ConnectionNetworkController.swift in Sources */,
930952
1D7918412227202700429936 /* Reachability.swift in Sources */,
931953
FC22B19421ACA54000738023 /* ImageCache.swift in Sources */,
932954
1DFE02072190E2E600856ABC /* Notification+Redirect.swift in Sources */,
933955
FCF0C4E421B0A97000DEB117 /* ConnectionNetworkError.swift in Sources */,
956+
DE1F037226A8AD2600B6CF1A /* AuthenticationSessionPresentationContextProvider.swift in Sources */,
934957
1DFE02052190E25500856ABC /* ConnectionCredentialProvider.swift in Sources */,
935958
DE328DC8243E2FC300603EAC /* SynchronizationTriggerEvent.swift in Sources */,
936959
FC094BA7215ED72F008B35F6 /* Color.swift in Sources */,
@@ -959,6 +982,7 @@
959982
FC094BA5215ED6F5008B35F6 /* UIFont+CommonValues.swift in Sources */,
960983
1DFE020D2190E3DB00856ABC /* API.swift in Sources */,
961984
FCBA16052138A4EE00EB1BC8 /* Connection.swift in Sources */,
985+
DE1F036D26A8A29800B6CF1A /* SignInWithAppleAuthentication.swift in Sources */,
962986
DEC08FFA242A5DD4007D7039 /* ConnectionsMonitor.swift in Sources */,
963987
DE3074A923DB50A800A3C71F /* Analytics+DataStructures.swift in Sources */,
964988
DEF4A4922587B9EB00735E98 /* Array+Helpers.swift in Sources */,
@@ -1189,7 +1213,6 @@
11891213
GCC_WARN_UNUSED_FUNCTION = YES;
11901214
GCC_WARN_UNUSED_VARIABLE = YES;
11911215
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
1192-
MARKETING_VERSION = 2.3.1;
11931216
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
11941217
MTL_FAST_MATH = YES;
11951218
ONLY_ACTIVE_ARCH = YES;
@@ -1247,7 +1270,6 @@
12471270
GCC_WARN_UNUSED_FUNCTION = YES;
12481271
GCC_WARN_UNUSED_VARIABLE = YES;
12491272
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
1250-
MARKETING_VERSION = 2.3.1;
12511273
MTL_ENABLE_DEBUG_INFO = NO;
12521274
MTL_FAST_MATH = YES;
12531275
SDKROOT = iphoneos;
@@ -1276,7 +1298,6 @@
12761298
"@executable_path/Frameworks",
12771299
"@loader_path/Frameworks",
12781300
);
1279-
MARKETING_VERSION = 2.4.2;
12801301
PRODUCT_BUNDLE_IDENTIFIER = "ifttt.IFTTT-SDK";
12811302
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
12821303
SKIP_INSTALL = YES;
@@ -1303,7 +1324,6 @@
13031324
"@executable_path/Frameworks",
13041325
"@loader_path/Frameworks",
13051326
);
1306-
MARKETING_VERSION = 2.4.2;
13071327
PRODUCT_BUNDLE_IDENTIFIER = "ifttt.IFTTT-SDK";
13081328
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
13091329
SKIP_INSTALL = YES;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//
2+
// ASWebServiceAuthentication.swift
3+
// IFTTTConnectSDK
4+
//
5+
// Copyright © 2021 IFTTT. All rights reserved.
6+
//
7+
8+
import AuthenticationServices
9+
10+
/// Wraps an `ASWebAuthenticationSession`. Used to authenticate web services on iOS 12 and up.
11+
@available(iOS 12.0, *)
12+
final class ASWebServiceAuthentication: WebServiceAuthentication {
13+
14+
/// The backing `ASWebAuthenticationSession`.
15+
private var session: ASWebAuthenticationSession?
16+
17+
/// We must hold a reference to the session context provider so it's not deallocated.
18+
/// Only used with `ASWebAuthenticationSession` in iOS 13 and up.
19+
private var authenticationSessionContextPresentationProvider: AuthenticationSessionContextPresentationProvider?
20+
21+
/// Creates an instance of ASWebServiceAuthentication.
22+
/// - Parameters
23+
/// - authenticationSessionContextProvider: An optional instance of `AuthenticationSessionContextPresentationProvider` used in configuring the web service authentication object. Optional for iOS 12 but required for iOS 13 and up.
24+
init(authenticationSessionContextPresentationProvider: AuthenticationSessionContextPresentationProvider?) {
25+
self.authenticationSessionContextPresentationProvider = authenticationSessionContextPresentationProvider
26+
}
27+
28+
@discardableResult
29+
override func start(with parameters: Parameters, completionHandler: @escaping (Result<URL, AuthenticationError>) -> Void) -> Bool {
30+
let asWebAuthenticationSession = ASWebAuthenticationSession(url: parameters.url,
31+
callbackURLScheme: parameters.callbackURLScheme) { url, error in
32+
guard let url = url else {
33+
guard let error = error as? ASWebAuthenticationSessionError else {
34+
completionHandler(.failure(.unknown))
35+
return
36+
}
37+
switch error.code {
38+
case .canceledLogin:
39+
completionHandler(.failure(.userCanceled))
40+
default:
41+
completionHandler(.failure(.unknown))
42+
}
43+
return
44+
}
45+
completionHandler(.success(url))
46+
}
47+
48+
if #available(iOS 13.0, *) {
49+
asWebAuthenticationSession.presentationContextProvider = authenticationSessionContextPresentationProvider
50+
asWebAuthenticationSession.prefersEphemeralWebBrowserSession = parameters.prefersEphemeralWebBrowserSession
51+
}
52+
self.session = asWebAuthenticationSession
53+
return asWebAuthenticationSession.start()
54+
}
55+
56+
override func cancel() {
57+
session?.cancel()
58+
}
59+
}

0 commit comments

Comments
 (0)