google / GoogleSignIn-iOS

Enables iOS and macOS apps to sign in with Google.
https://developers.google.com/identity/sign-in/ios
Apache License 2.0
506 stars 201 forks source link

Debuger is not working due to the GoogleSignIn 7.0.0 #293

Closed amadeuszpolak closed 11 months ago

amadeuszpolak commented 1 year ago

Describe the bug

While debugging in project, I have an issue with "po" commend. When trying to "po" some variable I got an error like this:

"warning: Swift error in scratch context: /Users/Project/Pods/Headers/Public/ProjectDependency/MCSGoogleSignIn.h:9:9: note: while building module 'GoogleSignIn' imported from /Users/Project/Pods/Headers/Public/ProjectDependency/MCSGoogleSignIn.h:9:
#import <GoogleSignIn/GoogleSignIn.h>
        ^

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "GoogleSignIn-umbrella.h"
        ^

/Users/Project/Pods/Headers/Public/GoogleSignIn/GoogleSignIn-umbrella.h:14:9: note: in file included from /Users/Project/Pods/Headers/Public/GoogleSignIn/GoogleSignIn-umbrella.h:14:
#import "GIDGoogleUser.h"
        ^

error: /Users/Project/Pods/Headers/Public/GoogleSignIn/GIDGoogleUser.h:29:9: error: module 'GTMAppAuth' not found
@import GTMAppAuth;
        ^

/Users/Project/EE_iOS/Supporting Files/EE_iOS_Bridging_Header.h:286:9: note: in file included from /Users/Project/Supporting Files/EE_iOS_Bridging_Header.h:286:
#import <ProjectDependency/MCSGoogleSignIn.h>
        ^

error: /Users/Project/Pods/Headers/Public/ProjectDependency/MCSGoogleSignIn.h:9:9: error: could not build module 'GoogleSignIn'
#import <GoogleSignIn/GoogleSignIn.h>
        ^

error: failed to import bridging header '/Users/Project/Supporting Files/EE_iOS_Bridging_Header.h'
.
Shared Swift state for Project.app has developed fatal errors and is being discarded.
REPL definitions and persistent names/types will be lost.

error: expression failed to parse:
unknown error" 

GoogleSignIn 7.0.0 is a cocoapod dependency of my internal pod dependency. (It is not used as a SWIFT PACKAGE!)

Bug can be fixed by replacing in GIDGoogleUser:

#ifdef SWIFT_PACKAGE
@import GTMAppAuth;
#else
#import <GTMAppAuth/GTMAppAuthFetcherAuthorization.h>
#endif

by this:

#import <GTMAppAuth/GTMAppAuthFetcherAuthorization.h> To Reproduce

Expected behavior variable should be print out

Environment

anatoli-tsinovoy commented 1 year ago

We're experiencing the same thing, but with 6.2.4. In 6.2.4 the offending import is in GIDAuthentication.h rather than GIDGoogleUser

frankiesimon commented 1 year ago

We're experiencing the same issue - thanks @amadeuszpolak - your workaround helped.

However we're not sure why the SWIFT_PACKAGE flag is on in the first place since we're also only using the dependency from Cocoapods.

Any idea when this can be fixed for us?

mdmathias commented 1 year ago

Hi all. Sorry for the delay.

I'm not able to reproduce this issue. I created a new test app (iOS, Swift), and added a Podfile like the below:

target 'Test' do
  use_frameworks!
  pod 'GoogleSignIn', '~> 7.0.0'
end

I then ran pod install and opened the resulting Test.xcworkspace. Next, I just imported GoogleSignIn into a file, exercised GIDSignIn a bit, added a breakpoint, and ran the app. When execution paused at the breakpoint, I ran po gid in the console and saw output (and no crash). See below for what the file looked like:

//
//  ViewController.swift
//  Test

import UIKit
import GoogleSignIn

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    let gid = GIDSignIn.sharedInstance
    print(gid)
  }

}

Could I get more detailed reproduction steps? It would be nice to also have a link to a project with this issue. Instructions like the below would help:

  1. Checkout project XYZ (link to GitHub, for example)
  2. cd to project XYZ
  3. Run pod install
  4. Open the resulting .xcworkspace
  5. Put a breakpoint in file ABC
  6. Run the app/library
  7. Execute po someValue
  8. Note crash with the following output (output of crash pasted in message below)
jovandgo commented 1 year ago

It seems that the same issue can be reproduced by:

  1. Creating a new UIKit project
  2. Adding GoogleSignIn v7.0.0 as a pod
  3. Adding FacebookCore from the Facebook SDK for iOS v16.1.3 (https://github.com/facebook/facebook-ios-sdk) as a Swift package
  4. Specifying import GoogleSignIn in the initial view controller's file
  5. Adding a breakpoint in the initial view controller's viewDidLoad
  6. Running the app
  7. At the breakpoint: printing po navigationController

GoogleSignIn v6.1.0 is the latest that doesn't cause the same issue.

brnnmrls commented 11 months ago

Hi folks, touching on this issue again.

Unfortunately, I am unable to reproduce this issue. My attempt looked like the following:

  1. Create a new test app - UIKit project
  2. Created a pod file and added GoogleSignIn v7.0.0 as a pod.
  3. Ran pod install and opened the created Test.xcworkspace
  4. Added FacebookCore from Facebook SDK for iOS as a Swift package
  5. Imported GoogleSignIn and FacebookCore in view controller file
  6. Exercise GIDSignIn in view controller like below:
    super.viewDidLoad()
    let gid = GIDSignIn.sharedInstance
    print(gid)
    }
  7. Added a breakpoint at print(gid) and ran the app
  8. At breakpoint: ran command po gid in console

At this point I received output and no crash. For more context, I'm using the following versions:

  1. cocoapods v1.11.2
  2. Xcode v15.0.1
  3. FacebookCore v16.2.1
  4. GoogleSignIn v7.0.0

I'll be closing this issue as "Can't repro" but if you continue to still encounter the error then please give reproduction steps and any other information (screenshots, stack traces, etc.) that could help me reproduce it, so we can open this up again.

jovandgo commented 11 months ago

Hi folks, touching on this issue again.

Unfortunately, I am unable to reproduce this issue. My attempt looked like the following:

  1. Create a new test app - UIKit project
  2. Created a pod file and added GoogleSignIn v7.0.0 as a pod.
  3. Ran pod install and opened the created Test.xcworkspace
  4. Added FacebookCore from Facebook SDK for iOS as a Swift package
  5. Imported GoogleSignIn and FacebookCore in view controller file
  6. Exercise GIDSignIn in view controller like below:
    super.viewDidLoad()
    let gid = GIDSignIn.sharedInstance
    print(gid)
  }
  1. Added a breakpoint at print(gid) and ran the app
    1. At breakpoint: ran command po gid in console

At this point I received output and no crash. For more context, I'm using the following versions:

  1. cocoapods v1.11.2
  2. Xcode v15.0.1
  3. FacebookCore v16.2.1
  4. GoogleSignIn v7.0.0

I'll be closing this issue as "Can't repro" but if you continue to still encounter the error then please give reproduction steps and any other information (screenshots, stack traces, etc.) that could help me reproduce it, so we can open this up again.

@brnnmrls Did you try po navigationController in the debugger at the breakpoint?

brnnmrls commented 11 months ago

@jovandgo Yes, I did. I went ahead and added the navigation controller, I was able to see an instance and no crash. Additionally, I changed the version of FacebookCore to use v16.1.3 to follow your reproduction steps.

A suggestion would be to narrow the scope by removing the FacebookCore dependency and keeping GoogleSignIn, running the app, then running the "po" command. These steps should then be repeated by removing GoogleSignIn and keeping FacebookCore. It's unlikely but this is meant to check if the error is thrown whenever the dependencies are imported together or specific to a single one.

An additional thought refers to the initial comment on this thread where "GoogleSignIn 7.0.0 is a cocoapod dependency of my internal pod dependency. (It is not used as a SWIFT PACKAGE!)" Could I get a bit clarification on what this may mean? Our interpretation on this was creating an app that uses a pod file to pull in GoogleSignIn v7.0.0 while Swift package manager pulls in another dependency, in this case FacebookCore. Any information would be great!