From 0cb046296af150d24a4d053d9cde0765890cc44a Mon Sep 17 00:00:00 2001 From: Peter Friese Date: Sun, 17 Jul 2022 20:30:28 +0200 Subject: [PATCH 1/3] Make asynchronous methods callable via async/await This fixes #91 --- .../Sources/Public/GoogleSignIn/GIDSignIn.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index 094dffb1..387d891a 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -122,6 +122,7 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); - (void)signInWithConfiguration:(GIDConfiguration *)configuration presentingViewController:(UIViewController *)presentingViewController callback:(nullable GIDSignInCallback)callback + __attribute__((swift_async_name("signIn(with:presenting:)"))) NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions."); /// Starts an interactive sign-in flow on iOS using the provided configuration and a login hint. @@ -143,6 +144,7 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); presentingViewController:(UIViewController *)presentingViewController hint:(nullable NSString *)hint callback:(nullable GIDSignInCallback)callback + __attribute__((swift_async_name("signIn(with:presenting:hint:)"))) NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions."); /// Starts an interactive sign-in flow on iOS using the provided configuration and a login hint. @@ -165,7 +167,8 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); presentingViewController:(UIViewController *)presentingViewController hint:(nullable NSString *)hint additionalScopes:(nullable NSArray *)additionalScopes - callback:(nullable GIDSignInCallback)callback; + callback:(nullable GIDSignInCallback)callback + __attribute__((swift_async_name("signIn(with:presenting:hint:additionalScopes:)"))); /// Starts an interactive consent flow on iOS to add scopes to the current user's grants. /// @@ -181,6 +184,7 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); - (void)addScopes:(NSArray *)scopes presentingViewController:(UIViewController *)presentingViewController callback:(nullable GIDSignInCallback)callback + __attribute__((swift_async_name("addScopes(_:presenting:)"))) NS_EXTENSION_UNAVAILABLE("The add scopes flow is not supported in App Extensions."); #elif TARGET_OS_OSX @@ -198,6 +202,7 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); - (void)signInWithConfiguration:(GIDConfiguration *)configuration presentingWindow:(NSWindow *)presentingWindow callback:(nullable GIDSignInCallback)callback; + __attribute__((swift_async_name("signIn(with:presenting:)"))); /// Starts an interactive sign-in flow on macOS using the provided configuration and a login hint. /// @@ -215,7 +220,8 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); - (void)signInWithConfiguration:(GIDConfiguration *)configuration presentingWindow:(NSWindow *)presentingWindow hint:(nullable NSString *)hint - callback:(nullable GIDSignInCallback)callback; + callback:(nullable GIDSignInCallback)callback + __attribute__((swift_async_name("signIn(with:presenting:hint)"))); /// Starts an interactive sign-in flow on macOS using the provided configuration and a login hint. /// @@ -236,7 +242,8 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); presentingWindow:(NSWindow *)presentingWindow hint:(nullable NSString *)hint additionalScopes:(nullable NSArray *)additionalScopes - callback:(nullable GIDSignInCallback)callback; + callback:(nullable GIDSignInCallback)callback + __attribute__((swift_async_name("signIn(with:presenting:hint:additionalScopes:)"))); /// Starts an interactive consent flow on macOS to add scopes to the current user's grants. /// @@ -249,7 +256,8 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); /// called asynchronously on the main queue. - (void)addScopes:(NSArray *)scopes presentingWindow:(NSWindow *)presentingWindow - callback:(nullable GIDSignInCallback)callback; + callback:(nullable GIDSignInCallback)callback + __attribute__((swift_async_name("addScopes(_:presenting:)"))); #endif From 664620b1ff369b2819a6d78f7690f72d2a97efff Mon Sep 17 00:00:00 2001 From: Peter Friese Date: Sun, 17 Jul 2022 22:54:58 +0200 Subject: [PATCH 2/3] Fix declarations --- GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index 387d891a..70d25c5f 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -201,7 +201,7 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); /// called asynchronously on the main queue. - (void)signInWithConfiguration:(GIDConfiguration *)configuration presentingWindow:(NSWindow *)presentingWindow - callback:(nullable GIDSignInCallback)callback; + callback:(nullable GIDSignInCallback)callback __attribute__((swift_async_name("signIn(with:presenting:)"))); /// Starts an interactive sign-in flow on macOS using the provided configuration and a login hint. @@ -221,7 +221,7 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); presentingWindow:(NSWindow *)presentingWindow hint:(nullable NSString *)hint callback:(nullable GIDSignInCallback)callback - __attribute__((swift_async_name("signIn(with:presenting:hint)"))); + __attribute__((swift_async_name("signIn(with:presenting:hint:)"))); /// Starts an interactive sign-in flow on macOS using the provided configuration and a login hint. /// From 67b07706d5bbbcdb0107bb7971c543ef9b1712ff Mon Sep 17 00:00:00 2001 From: Peter Friese Date: Thu, 21 Jul 2022 17:45:57 +0200 Subject: [PATCH 3/3] Fix lint warnings --- .../Sources/Public/GoogleSignIn/GIDSignIn.h | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h index 70d25c5f..2f02fb45 100644 --- a/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h +++ b/GoogleSignIn/Sources/Public/GoogleSignIn/GIDSignIn.h @@ -122,7 +122,9 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); - (void)signInWithConfiguration:(GIDConfiguration *)configuration presentingViewController:(UIViewController *)presentingViewController callback:(nullable GIDSignInCallback)callback +#if __has_attribute(swift_async_name) __attribute__((swift_async_name("signIn(with:presenting:)"))) +#endif NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions."); /// Starts an interactive sign-in flow on iOS using the provided configuration and a login hint. @@ -144,7 +146,9 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); presentingViewController:(UIViewController *)presentingViewController hint:(nullable NSString *)hint callback:(nullable GIDSignInCallback)callback +#if __has_attribute(swift_async_name) __attribute__((swift_async_name("signIn(with:presenting:hint:)"))) +#endif NS_EXTENSION_UNAVAILABLE("The sign-in flow is not supported in App Extensions."); /// Starts an interactive sign-in flow on iOS using the provided configuration and a login hint. @@ -168,7 +172,10 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); hint:(nullable NSString *)hint additionalScopes:(nullable NSArray *)additionalScopes callback:(nullable GIDSignInCallback)callback - __attribute__((swift_async_name("signIn(with:presenting:hint:additionalScopes:)"))); +#if __has_attribute(swift_async_name) + __attribute__((swift_async_name("signIn(with:presenting:hint:additionalScopes:)"))) +#endif +; /// Starts an interactive consent flow on iOS to add scopes to the current user's grants. /// @@ -184,7 +191,9 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); - (void)addScopes:(NSArray *)scopes presentingViewController:(UIViewController *)presentingViewController callback:(nullable GIDSignInCallback)callback +#if __has_attribute(swift_async_name) __attribute__((swift_async_name("addScopes(_:presenting:)"))) +#endif NS_EXTENSION_UNAVAILABLE("The add scopes flow is not supported in App Extensions."); #elif TARGET_OS_OSX @@ -202,7 +211,10 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); - (void)signInWithConfiguration:(GIDConfiguration *)configuration presentingWindow:(NSWindow *)presentingWindow callback:(nullable GIDSignInCallback)callback - __attribute__((swift_async_name("signIn(with:presenting:)"))); +#if __has_attribute(swift_async_name) + __attribute__((swift_async_name("signIn(with:presenting:)"))) +#endif +; /// Starts an interactive sign-in flow on macOS using the provided configuration and a login hint. /// @@ -221,7 +233,10 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); presentingWindow:(NSWindow *)presentingWindow hint:(nullable NSString *)hint callback:(nullable GIDSignInCallback)callback - __attribute__((swift_async_name("signIn(with:presenting:hint:)"))); +#if __has_attribute(swift_async_name) + __attribute__((swift_async_name("signIn(with:presenting:hint:)"))) +#endif +; /// Starts an interactive sign-in flow on macOS using the provided configuration and a login hint. /// @@ -243,7 +258,10 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); hint:(nullable NSString *)hint additionalScopes:(nullable NSArray *)additionalScopes callback:(nullable GIDSignInCallback)callback - __attribute__((swift_async_name("signIn(with:presenting:hint:additionalScopes:)"))); +#if __has_attribute(swift_async_name) + __attribute__((swift_async_name("signIn(with:presenting:hint:additionalScopes:)"))) +#endif +; /// Starts an interactive consent flow on macOS to add scopes to the current user's grants. /// @@ -257,7 +275,10 @@ typedef void (^GIDDisconnectCallback)(NSError *_Nullable error); - (void)addScopes:(NSArray *)scopes presentingWindow:(NSWindow *)presentingWindow callback:(nullable GIDSignInCallback)callback - __attribute__((swift_async_name("addScopes(_:presenting:)"))); +#if __has_attribute(swift_async_name) + __attribute__((swift_async_name("addScopes(_:presenting:)"))) +#endif +; #endif