mirzemehdi / KMPAuth

Kotlin Multiplatform Authentication Library targetting android and iOS
https://mirzemehdi.com/KMPAuth/
Apache License 2.0
231 stars 19 forks source link

iOS build Linking errors when running the simulator with Firebase Google Signin Auth #42

Closed santyas closed 3 months ago

santyas commented 3 months ago

Hello Mirzamehdi!

First I want to thank you for your help and the effort you make with this project :)

I followed your steps to use the google sign-in with firebase auth but I can't run it on my ios simulator. Inside android console I get this error:

ld: warning: search path '/Users/me/app/iosApp/../shared/build/xcode-frameworks/Debug/iphonesimulator17.2' not found
ld: warning: search path '/Users/me/app/iosApp/../composeApp/build/xcode-frameworks/Debug/iphonesimulator17.2' not found
ld: warning: Could not find or use auto-linked framework 'CoreAudioTypes': framework 'CoreAudioTypes' not found
ld: warning: Could not find or use auto-linked framework 'FirebaseAuth': framework 'FirebaseAuth' not found
ld: warning: Could not find or use auto-linked framework 'FirebaseCore': framework 'FirebaseCore' not found
ld: warning: Could not find or use auto-linked framework 'GoogleSignIn': framework 'GoogleSignIn' not found
ld: Undefined symbols:
  _FIRAuthErrorDomain, referenced from:
      _cocoapods_FirebaseAuth_FIRAuthErrorDomain_getter_wrapper0 in ComposeApp[2720](libdev.gitlive:firebase-auth-cinterop-FirebaseAuth-cache.a.o)
  _OBJC_CLASS_$_FIRAuth, referenced from:
       in ComposeApp[2734](libdev.gitlive:firebase-auth-cache.a.o)
  _OBJC_CLASS_$_FIRAuthDataResult, referenced from:
       in ComposeApp[2734](libdev.gitlive:firebase-auth-cache.a.o)
  _OBJC_CLASS_$_FIRGoogleAuthProvider, referenced from:
       in ComposeApp[2734](libdev.gitlive:firebase-auth-cache.a.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

** BUILD FAILED **

The following build commands failed:
    Ld /Users/me/app/build/ios/Debug-iphonesimulator/App.app/App normal (in target 'iosApp' from project 'iosApp')
(1 failure)

Also I tried to run it inside xcode but: xcode-build

I've installed firebase and googlesignin packages into xcode by File > Package dependencies... I'm using compose multiplatform (from jetbrains wizard) and Kotlin 2.0.

Please let me know if you need to see some piece of code :)

santyas commented 3 months ago

Well chatgpt suggest me config a podfile with firebase google etc pods inside. I think isn't necessary bc in your example this config isn't exist. I've also cloned your repo and without any aditional config it ran the ios sim perfectly 🫤 What am I missing?

mirzemehdi commented 3 months ago

@santyas looks like something is wrong with your ios dependencies, because from logs it seems like it can't find Firebase or GoogleSignIn dependencies. Maybe in XCode check that in iosApp target -> Framework, Libraries section GoogleSignIn and FirebaseAuth is added. Also try clean -> rebuild, gradle resync to see what happens

mirzemehdi commented 3 months ago

Not sure if it would be related, but another thing that I noticed in your logs it searches path both ../shared/ and ../composeApp path. Maybe you forgot somewhere to change shared module name. Just a guess

santyas commented 3 months ago

Maybe in XCode check that in iosApp target -> Framework, Libraries section GoogleSignIn and FirebaseAuth is added. Also try clean -> rebuild, gradle resync to see what happens

I can confirm that I added two dependencies

santyas commented 3 months ago

Not sure if it would be related, but another thing that I noticed in your logs it searches path both ../shared/ and ../composeApp path. Maybe you forgot somewhere to change shared module name. Just a guess

I have not detected it :O

mirzemehdi commented 3 months ago

@santyas maybe try in new project to see if it still happens

mirzemehdi commented 3 months ago

also @santyas check this, looks like sometimes there can be problem with library/framework linking in XCode: https://stackoverflow.com/questions/33728359/when-do-you-have-to-link-frameworks-and-libraries-to-an-xcode-project

santyas commented 3 months ago

also @santyas check this, looks like sometimes there can be problem with library/framework linking in XCode: https://stackoverflow.com/questions/33728359/when-do-you-have-to-link-frameworks-and-libraries-to-an-xcode-project

Interesting to keep in mind. But I noticed that I updated the basename and bundlename in previous commits, so possibly this has unlinked something 🫤 I started a new project without edit it and KMPAuth works perfect 👍🏻

mirzemehdi commented 3 months ago

@santyas same issue actually occurred to me today. Thanks for mentioning this. When I look at in XCode frameworks that project uses, I saw that it is missiong out FirebaseAuth. So in case someone has same problem make sure in your framework/libraries sections these exists. (FirebaseMessaging you can ignore it was added for Push Notifications)

image