google / GTMAppAuth

Apple platforms SDK for using AppAuth with Google libraries.
Apache License 2.0
370 stars 193 forks source link

App Extensions unsupported? #87

Open mmcguill opened 5 years ago

mmcguill commented 5 years ago

Hi there, I just updated my pods and it appears things are now broken for my App Extension.

I believe I link to this library via:

pod 'GoogleSignIn'

My app allows people to store their password databases on Google Drive and I provide an App Extension (Credential AutoFill) to allow them to select their passwords inline from within say Safari.

It looks like the library you use AppAuth is not built/designed for use in App Extensions.

This seems to be a change with GoogleSignIn 5.0.0?

Are there any plans to support App Extensions or at least not break when built as an App Extension as before.

Will revert to 4.4.0 for now.

Thanks! -Mark

StevenEWright commented 5 years ago

Mark, could you provide any details about what is failing? Also, have you considered filing a bug/feature request with AppAuth?

mmcguill commented 5 years ago

Hi @StevenEWright

Sure, yes, thought you guys might have been aware of the issue or that it was a conscious decision to not support App Extensions, which is why I didn't include extra detail.

I was looking at this which made me think that:

https://github.com/google/GTMAppAuth/issues/76

The issues are the standard run of the mill issues that occur in App Extensions, screenshot below.

image

Build Output Errors:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:111:54: note: 'sharedApplication' has been explicitly marked unavailable here /Users/mark/dev/strongbox/Pods/AppAuth/Source/iOS/OIDExternalUserAgentIOSCustomBrowser.m:142:23: error: 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead. [[UIApplication sharedApplication] openURL:_appStoreURL]; ^ In module 'UIKit' imported from /Users/mark/dev/strongbox/Pods/Target Support Files/AppAuth/AppAuth-prefix.pch:2: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:111:54: note: property 'sharedApplication' is declared unavailable here @property(class, nonatomic, readonly) UIApplication *sharedApplication NS_EXTENSION_UNAVAILABLE_IOS("Use view controller based solutions where appropriate instead."); ^ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.4.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:111:54: note: 'sharedApplication' has been explicitly marked unavailable here /Users/mark/dev/strongbox/Pods/AppAuth/Source/iOS/OIDExternalUserAgentIOSCustomBrowser.m:142:42: error: 'openURL:' is unavailable: not available on iOS (App Extension) [[UIApplication sharedApplication] openURL:_appStoreURL];

StevenEWright commented 5 years ago

@mmcguill Ah, yes, now I vaguely remember. IIRC, AppAuth does have support for extensions but probably the maintainers of GTMAppAuth will need to make pod subspecs to support this, and maybe more? Thanks for the additional info!

SteveDCronin commented 4 years ago

I have the same question regarding app extensions (an iOS .appex) but from a different failure point.

When I run the following code inside the hosting iOS app it works as expected. When I run the same code inside of one of my .appex it fails (the returned value is nil) Please advise as to whether this is due to inherent limitation of .appex (no keychain access??) or if this might be a bug and the method will be improved in the future.

BTW: This result is obtained even if Keychain Sharing capability has been turned ON for both the host app and the embedded apex. NOTE: still works properly in app itself and returns nil in the .appex.

if (googleAuthorization==nil) { googleAuthorization=[GTMAppAuthFetcherAuthorization authorizationFromKeychainForName:kGTMAppAuthKeychainItemName]; } return googleAuthorization;

SteveDCronin commented 4 years ago

Hoping for some guidance! I have an iOS app that implements GMTAppAuth just fine. Upon signIn I serialize by using the 'saveAuthorization:toKeychainForName:'... As needed I can then use 'authorizationFromKeychainForName:'. Inside the host .app this all works as expected. I also would like to use this within an embedded .appex. However when I attempt to use 'authorizationFromKeychainForName:' this returns nil. Is this because the .appex cannot retrieve that which was stored by the .app? Is this a limitation of the implementation that StevenEWright seems to be alluding to? Any clarifying thoughts appreciated!

NSRover commented 4 years ago

@mmcguill @StevenEWright I can't tell if you guys resolved this issue or not. Can GoogleSignIn be used from an iOS App Extension?

mmcguill commented 4 years ago

I'm afraid I didn't resolve in the end, and have moved to a different strategy for my app which doesn't involve using this library in my App Extension.