Google Sign In not working on iOS 10 Beta 7 with X

2019-01-23 16:31发布

问题:

I have an app in the app store which worked perfectly fine till first few betas of iOS 10 (i am not exactly sure which one). It also works perfectly fine on iOS 9.3.

However I am not testing on iOS 10 beta 7 and the google sign in is completely broken. I am using the latest version of GIDSignIn from cocoapods.

Here's my code:

[GIDSignIn sharedInstance].clientID = [[ParseFetcher sharedInstance] getRandomParseK];
[GIDSignIn sharedInstance].delegate = sharedInstance;
[GIDSignIn sharedInstance].uiDelegate=sharedInstance;
[GIDSignIn sharedInstance].scopes = [NSArray arrayWithObjects:@"https://www.googleapis.com/auth/youtube",@"https://www.googleapis.com/auth/youtube.force-ssl", nil];
[[GIDSignIn sharedInstance] signIn];

This is how it looks like on device:

It just stays stuck like this.

If I click the refresh button at top, it tries to refresh and gets stuck here forever.

Clicking on the done button sends me back to my app.

There are no errors logged in the console.

However, when I run the same app on iOS 10 simulator, the safari view controller doesn't even open. Nothing happens at all. But the console logs this long verbose stuff out of which the following seems like the most "useful" stuff but I have no clue what's wrong:

nw_endpoint_resolver_receive_report [8 i.ytimg.com:443 in_progress resolver (satisfied)] received child report:[8.1 206.248.149.148:443 waiting path (satisfied)]
2016-08-22 23:19:51.531570 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_connection_endpoint_report [8.1 206.248.149.148:443 waiting path (satisfied)] reported event path:satisfied
2016-08-22 23:19:51.531909 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_endpoint_proxy_handler_should_use_proxy Looking up proxy for hostname: <nil>, ifindex: 0
2016-08-22 23:19:51.533116 XXXXAPPNAMEXXXXXXX[4561:195631] [] -[NWConcrete_nw_endpoint_flow startWithHandler:] [8.1 206.248.149.148:443 waiting socket-flow (satisfied)]
2016-08-22 23:19:51.533548 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_endpoint_flow_setup_socket [8.1 206.248.149.148:443 in_progress socket-flow (satisfied)] creating socket
2016-08-22 23:19:51.534108 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_endpoint_flow_attach_protocols [8.1 206.248.149.148:443 in_progress socket-flow (satisfied)]
2016-08-22 23:19:51.534672 XXXXAPPNAMEXXXXXXX[4561:195631] [] __nwlog_err_simulate_crash simulate crash already simulated "nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available"
2016-08-22 23:19:51.535415 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_socket_set_common_sockopts setsockopt SO_NOAPNFALLBK failed: [42] Protocol not available, dumping backtrace:
        [x86_64] libnetcore-856.1.8
    0   libsystem_network.dylib             0x000000010c6e280e __nw_create_backtrace_string + 123
    1   libnetwork.dylib                    0x000000010e0d5194 nw_socket_add_input_handler + 3002
    2   libnetwork.dylib                    0x000000010e0b2db8 nw_endpoint_flow_attach_protocols + 3768
    3   libnetwork.dylib                    0x000000010e0b1dd5 nw_endpoint_flow_setup_socket + 563
    4   libnetwork.dylib                    0x000000010e0b0b34 -[NWConcrete_nw_endpoint_flow startWithHandler:] + 2612
    5   libnetwork.dylib                    0x000000010e0cbd11 nw_endpoint_handler_path_change + 1261
    6   libnetwork.dylib                    0x000000010e0cb740 nw_endpoint_handler_start + 570
    7   libnetwork.dylib                    0x000000010e0e3003 nw_endpoint_resolver_start_next_child + 2240
    8   libdispatch.dylib                   0x000000
2016-08-22 23:19:51.535995 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_endpoint_flow_attach_protocols [8.1 206.248.149.148:443 in_progress socket-flow (satisfied)] Attached flow protocol
2016-08-22 23:19:51.536475 XXXXAPPNAMEXXXXXXX[4561:195631] [] nw_endpoint_resolver_receive_report [8 i.ytimg.com:443 in_progress resolver (satisfied)] received child report:[8.1 206.248.149.148:443 in_progress socket-flow (satisfied)]

NOTE: iOS 9.3 works perfectly. Also happens on all devices - tested on iPhone 6s and iPhone 5s.

回答1:

Google SignIn sample iOS project too has the same issue.

It returns:

"Error Domain=com.google.GIDSignIn Code=-2 "keychain error" UserInfo={NSLocalizedDescription=keychain error}"

This seems to be a bug.



回答2:

I'm (still) using Google+ SDK for sign-in (1.7.1), and it also broken on iOS 10 beta 7. I was thinking about moving to GIDSignIn since GPPSignIn is deprecated. but I guess I will wait for next beta...



回答3:

Turn on "Keychain Sharing" in the capabilities tab of your target and it will work.



回答4:

I am not sure if this is what other people are facing but I solved it by adding a [self.view layoutIfNeeded]. I know this is weird but this is what worked for me, I am myself not sure why.

I was using a custom view container inside which I was showing the Google's sign in view controller as a child. So before adding the custom view controller to the container, i had to do [self.view layoutIfNeeded] as else the view layout hadn't been set yet, so google's sdk probably uses the width/height somewhere inside.

I am not sure if this is the right solution but it seems to have fixed my issue.



回答5:

I am able to find a solution in my case by fixing my code to present a subview properly. Before I was getting this warning but ignored it:

Warning :-Presenting view controllers on detached view controllers is discouraged

until I saw Pranoy C's answer. My code is structured in a very similar way that a view container is used to present subviews which contain the Google button. It was not using the container correctly to present a subview. So I followed Apple's guide, especially this block:

- (void) displayContentController: (UIViewController*) content {
    [self addChildViewController:content];
    content.view.frame = [self frameForContentController];
    [self.view addSubview:self.currentClientView];
    [content didMoveToParentViewController:self];
}

Once the warning was gone, Google started to work properly.

As far as root cause of this issue, I'm still not exactly sure, but the warning seems to be a hint. It has to do with detached view controllers. (I'm not super experienced at iOS coding, so if someone has more knowledge with views, view controllers, feel free to chime in.)



回答6:

Our issue was some third party plugins trying to auto integrate into our app delegate. For us, it was CleverTap (the autoIntegrate() function).



回答7:

Do Nothing Just set the clientID while application is being finished launching. Like Given in the code below:

import FBSDKLoginKit import GoogleSignIn import GGLCore

@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {


    var ConfigError : NSError?
    GGLContext.sharedInstance().configureWithError(&ConfigError)
    assert(ConfigError == nil, "Error Configuration with Google services: \(ConfigError)")
    GIDSignIn.sharedInstance().clientID = "679401366566-8107g2n11hpnqas58m9v8rk7hl2lgl7s.apps.googleusercontent.com" // Here You Have To Change Your App ID

    let fbDelegate = FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
    print("DidFinish")

    return fbDelegate
}