diff --git a/FBSDKCoreKit/FBSDKCoreKit/FBSDKInternalUtility.m b/FBSDKCoreKit/FBSDKCoreKit/FBSDKInternalUtility.m index e78be08b4c..e4696692dc 100644 --- a/FBSDKCoreKit/FBSDKCoreKit/FBSDKInternalUtility.m +++ b/FBSDKCoreKit/FBSDKCoreKit/FBSDKInternalUtility.m @@ -327,12 +327,14 @@ - (nullable NSURL *)URLWithScheme:(NSString *)scheme host ?: @"", path ?: @"", queryString ?: @""]; - NSURL *url; + NSURL *url = [NSURL URLWithString:urlString]; + +#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 170000 if (@available(iOS 17.0, *)) { url = [NSURL URLWithString:urlString encodingInvalidCharacters:NO]; - } else { - url = [NSURL URLWithString:urlString]; } +#endif + if (errorRef != NULL) { if (url) { *errorRef = nil; diff --git a/FBSDKCoreKit/FBSDKCoreKit/Profile+Loading.swift b/FBSDKCoreKit/FBSDKCoreKit/Profile+Loading.swift index 0691c1f23f..454ef7d2fa 100644 --- a/FBSDKCoreKit/FBSDKCoreKit/Profile+Loading.swift +++ b/FBSDKCoreKit/FBSDKCoreKit/Profile+Loading.swift @@ -103,11 +103,14 @@ extension Profile { let rawLinkURL = response[ResponseKey.link.rawValue] as? String var linkURL = (response[ResponseKey.link.rawValue] as? URL) ?? (rawLinkURL.flatMap(URL.init(string:))) + + #if swift(>=5.9) if #available(iOS 17.0, *) { linkURL = (response[ResponseKey.link.rawValue] as? URL) ?? rawLinkURL.flatMap { str in URL(string: str, encodingInvalidCharacters: false) } } + #endif let friendsResponse = response[ResponseKey.friends.rawValue] as? [String: Any] let friends = friendsResponse.flatMap(friendIdentifiers(from:)) diff --git a/FBSDKCoreKit/FBSDKCoreKitTests/AppLinkNavigationTests.swift b/FBSDKCoreKit/FBSDKCoreKitTests/AppLinkNavigationTests.swift index 8898a6225f..ec69794e78 100644 --- a/FBSDKCoreKit/FBSDKCoreKitTests/AppLinkNavigationTests.swift +++ b/FBSDKCoreKit/FBSDKCoreKitTests/AppLinkNavigationTests.swift @@ -365,9 +365,11 @@ final class AppLinkNavigationTests: XCTestCase { func testNavigationTypeWithInvalidTargetWithoutWebUrl() { var url = URL(string: "invalid url") + #if swift(>=5.9) if #available(iOS 17.0, *) { url = URL(string: "invalid url", encodingInvalidCharacters: false) } + #endif let target = AppLinkTarget(url: url, appStoreId: nil, appName: name) let appLink = AppLink(sourceURL: nil, targets: [target], webURL: nil) navigation = AppLinkNavigation(appLink: appLink, extras: [:], appLinkData: [:]) @@ -405,9 +407,11 @@ final class AppLinkNavigationTests: XCTestCase { func testNavigationTypeWithInvalidTargetWithWebUrl() { var url = URL(string: "invalid url") + #if swift(>=5.9) if #available(iOS 17.0, *) { url = URL(string: "invalid url", encodingInvalidCharacters: false) } + #endif let target = AppLinkTarget(url: url, appStoreId: nil, appName: name) let appLink = AppLink(sourceURL: nil, targets: [target], webURL: .usingHost1) navigation = AppLinkNavigation(appLink: appLink, extras: [:], appLinkData: [:]) diff --git a/FBSDKCoreKit/FBSDKCoreKitTests/Internal/BridgeAPI/BridgeAPI+SessionCompletionHandlerTests.swift b/FBSDKCoreKit/FBSDKCoreKitTests/Internal/BridgeAPI/BridgeAPI+SessionCompletionHandlerTests.swift index 5056f1e9e0..72babed706 100644 --- a/FBSDKCoreKit/FBSDKCoreKitTests/Internal/BridgeAPI/BridgeAPI+SessionCompletionHandlerTests.swift +++ b/FBSDKCoreKit/FBSDKCoreKitTests/Internal/BridgeAPI/BridgeAPI+SessionCompletionHandlerTests.swift @@ -46,9 +46,11 @@ extension BridgeAPITests { func testInvokingAuthSessionCompletionHandlerFromHandlerWithInvalidURLWithoutError() { var url = URL(string: " ") + #if swift(>=5.9) if #available(iOS 17.0, *) { url = URL(string: " ", encodingInvalidCharacters: false) } + #endif var capturedSuccesses = [Bool]() var capturedErrors = [Error?]() let handler: SuccessBlock = { success, error in