Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Xcode 13 beta 3 #649

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,28 @@ import PackageDescription
limitations under the License.
*/

var platforms: [SupportedPlatform] {
#if compiler(<5.3)
return [
.macOS(.v10_10),
.iOS(.v8),
.tvOS(.v9),
.watchOS(.v2),
]
#else
// Xcode 12 (which ships with Swift 5.3) drops support for iOS 8
return [
.macOS(.v10_10),
.iOS(.v9),
.tvOS(.v9),
.watchOS(.v2),
]
#endif
}

let package = Package(
name: "AppAuth",
platforms: [
.macOS(.v10_10),
.iOS(.v8),
.tvOS(.v9),
.watchOS(.v2)
],
platforms: platforms,
products: [
.library(
name: "AppAuthCore",
Expand Down
15 changes: 11 additions & 4 deletions Source/AppAuth/iOS/OIDExternalUserAgentIOS.m
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,17 @@ - (BOOL)presentExternalUserAgentRequest:(id<OIDExternalUserAgentRequest>)request
openedUserAgent = YES;
}
}
// iOS 8 and earlier, use mobile Safari
if (!openedUserAgent){
openedUserAgent = [[UIApplication sharedApplication] openURL:requestURL];
}
// Xcode 13 beta 3 introduces a breaking change for APIs marked unavailable for iOS extensions
// https://developer.apple.com/documentation/xcode-release-notes/xcode-13-beta-release-notes
// The solution is to annotate apis that depend on APIs marked unavailable (sharedApplication, openURL).
// An easier solution is to remove those APIs in the first place.
// less than iOS 15, on Xcode 13
#if __IPHONE_OS_VERSION_MAX_ALLOWED < 150000
Comment on lines +166 to +171
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this issue is depends on not iOS 15 but Xcode 13, so this fix is no effect for earlier versions.
By using NS_EXTENSION_UNAVAILABLE_IOS macro for whole function, this issue will be fixed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that route first. As soon as you mark this function NS_EXTENSION_UNAVAILABLE_IOS , you have to mark all functions depending on this one with NS_EXTENSION_UNAVAILABLE_IOS in turn. You will need to do this in 4 places in this library, and the user of this library will have to also mark any of their methods that use one of these newly annotated methods with NS_EXTENSION_UNAVAILABLE_IOS

Instead of creating this cascading effect that will eventually end up in the users of this library, I have built upon the fact that if you're using Xcode 12 or above, you will need to use #604 that drops support for iOS 8. If you are using Xcode 13, you're definitely going to have to use #604 , so this code becomes irrelevant:

    // iOS 8 and earlier, use mobile Safari
     if (!openedUserAgent){
       openedUserAgent = [[UIApplication sharedApplication] openURL:requestURL];
     }

This code contains the only two apis that cause the need for NS_EXTENSION_UNAVAILABLE_IOS: sharedApplication and openURL . If we conditionally remove them for Xcode 13, the problem goes away.

// iOS 8 and earlier, use mobile Safari
if (!openedUserAgent){
openedUserAgent = [[UIApplication sharedApplication] openURL:requestURL];
}
#endif

if (!openedUserAgent) {
[self cleanUp];
Expand Down