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
478 stars 194 forks source link

SPM: Missing required module 'GoogleSignIn' #333

Closed hrabkin closed 1 year ago

hrabkin commented 1 year ago

Describe the bug

Swift Storyboard project with linked custom framework which has GoogleSign 7.0.0 as dependency When GoogleSignIn is linked as transitive dependency there's an error "Missing required module 'GoogleSignIn'"

To Reproduce Steps to reproduce the behavior:

  1. Create CustomFramework Swift iOS framework project, link GoogleSign 7.0.0 as dependency using SPM (swift package manager)
  2. Create GoogleSignTest Swift project with storyboards
  3. Link CustomFramework to GoogleSignTest project
  4. Build, see error

Expected behavior No errors

Screenshots Screenshot 2023-08-18 at 15 35 30

Screenshot 2023-08-18 at 15 29 09

Environment

Here's test project to reproduce framework-tests.zip

mdmathias commented 1 year ago

Hello! Sorry you're having a problem.

I think perhaps this is a consequence of your set up and not with the library itself. I've attached a demo project that you can use as a reference. Here's what I did:

  1. Create a new framework via Xcode.
  2. Depend on GoogleSignIn-iOS in this framework.
  3. Make sure to add @import GoogleSignIn; to the framework's header. See screenshot below.
  4. Save and close that Xcode project.
  5. Create another Xcode project that is an iOS app.
  6. Add the .xcodeproj for the framework that you created in the app's project navigator.
  7. In the app's .xcodeproj file, select the "General" tab and make sure to add the framework you created and added to the project navigator. See screenshot.
  8. Make sure to import your framework where you want to use it. See the screenshot below.

Screenshot 2023-08-18 at 10 37 53 AM image image

FrameworkDemo.zip

mdmathias commented 1 year ago

I'm closing this for now as I think the issue is resolved. Please feel free to comment here if you're finding a bug with the GoogleSignIn-iOS. If you do, please include reproduction steps.

hrabkin commented 1 year ago

Thanks for your quick feedback it helped to move on but I still experience issues with GoogleSignIn. Sorry might be a separate issue but unfortunately if I use the option I can't distribute my framework as XCFramework with GoogleSignIn dependency.

I see the following error at building Screenshot 2023-09-01 at 18 02 20

Here's demo project with aggregate target for XCFramework and linked GoogleSignIn dependency. FrameworkDemo 2.zip

I suppose it is something with module map exporting.

mdmathias commented 1 year ago

I don't know what you mean by the following:

Sorry might be a separate issue but unfortunately if I use the option I can't distribute my framework as XCFramework with GoogleSignIn dependency.

Sadly, I can't download your attached demo. Please list exact steps to reproduce your problem. Also, the screenshot of the error doesn't really help since I can't see the error. Please add any error you see as well.

In any case, did you reproduce the steps I listed above? It should work. I suggest you start from a clean project if you haven't already.

hrabkin commented 1 year ago

FrameworkDemo.2.zip

I can't build XCFramework with GoogleSignIn dependency. Including demo one more time, so that you could see the error output by your own eyes as how Xcode generates it, there's no more details about except those I have shared in the screenshot.

mdmathias commented 1 year ago

Sorry, I meant that I'm not going to download the zip. I don't mean to be rude; I just don't think it's a good practice.

In any case, please follow my suggestion in https://github.com/google/GoogleSignIn-iOS/issues/333#issuecomment-1703097828 and let me know what happens. If there is an issue, please provide the exact steps you took and the error you found. That will help me to reproduce and provide support.

hrabkin commented 1 year ago

@mdmathias oh well, its weird, why should you ask me to download your archive if its meant to be not a good practice. Anyway I have tried your approach, it works for my original sample but doesn't when I build xcframework. I hope steps of reproduction are more clear now and I have answered your question.

mdmathias commented 1 year ago

I'm sorry that it feels like a double standard; I am working with some restrictions due to my role.

I'm still not sure what error you're seeing. Also, I cannot reproduce the problem you describe. For example, in FrameworkDemo.zip above, you will see that there is a project that is just a framework: SwiftFrameworkTest. I am able to build that project. I also added a small file to SwiftFrameworkTest and added import GoogleSignIn to that file. I was able to create an instance of GIDSignIn as a property in that class and build without problem. I also was able to add a test target to the framework, and was able to create an instance of that class I made and assert that the GIDSignIn property was not nil.

I suggest that you break things down piece by piece. Build up piece-by-piece. It honestly feels like you have a problem with how your getting your dependencies.

Best of luck.

hrabkin commented 1 year ago

Ok, It works with simple framework, as I said that might be it should be a separate issue because it doesn't with XCFramework, full error: "failed to verify swift interface swift-interface-format-version: 1.0" pointing on GoogleSignIn at building it.

mdmathias commented 1 year ago

It looks like this might be a bug outside of GoogleSignIn: https://github.com/apple/swift/issues/64669. That link has some context and I think some workarounds that you might be able to try.