mirror of
https://github.com/zhigang1992/facebook-ios-sdk.git
synced 2026-04-30 10:22:53 +08:00
Fix Build issue in XCode 14
Summary: Fix backward compatibility for building the URL API for Xcode 14. In OC, we use __IPHONE_OS_VERSION_MAX_ALLOWED to check the iOS 17 SDK. In Swift, we use `#if swift(>=5.9)` to check the iOS 17 SDK (swift compiler is 5.9 in XCode 15) Reviewed By: sway-git, xta0 Differential Revision: D49626160 fbshipit-source-id: c702fb4208634720e78ed549ae6cd647f0f6e464
This commit is contained in:
committed by
Facebook GitHub Bot
parent
51ae3301ba
commit
de74c60d26
@@ -327,12 +327,14 @@ static FBSDKInternalUtility *_shared;
|
||||
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;
|
||||
|
||||
@@ -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:))
|
||||
|
||||
@@ -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: [:])
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user