question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linker errors when building for iOS

See original GitHub issue

Hi, in my KMM project, I’ve added the following to shared/build.gradle.kts:

sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("dev.gitlive:firebase-auth:1.0.0")
                ...

But when I try building the iOS application, I get the following linker errors:

.app/iosApp
ld: warning: Could not find or use auto-linked framework 'GoogleDataTransport'
ld: warning: Could not find or use auto-linked framework 'FirebaseCoreDiagnostics'
ld: warning: Could not find or use auto-linked framework 'FirebaseAnalytics'
ld: warning: Could not find or use auto-linked framework 'nanopb'
ld: warning: Could not find or use auto-linked framework 'FirebaseAuth'
ld: warning: Could not find or use auto-linked framework 'FIRAnalyticsConnector'
ld: warning: Could not find or use auto-linked framework 'GoogleUtilities'
ld: warning: Could not find or use auto-linked framework 'FirebaseCore'
ld: warning: Could not find or use auto-linked framework 'GoogleAppMeasurement'
ld: warning: Could not find or use auto-linked framework 'GTMSessionFetcher'
ld: warning: Could not find or use auto-linked framework 'FirebaseInstallations'
ld: warning: Could not find or use auto-linked framework 'PromisesObjC'
Undefined symbols for architecture x86_64:
  "_FIRAuthErrorDomain", referenced from:
      _cocoapods_FirebaseAuth_FIRAuthErrorDomain_getter_wrapper0 in shared(result.o)
     (maybe you meant: _cocoapods_FirebaseAuth_FIRAuthErrorDomain_getter_wrapper0, knifunptr_cocoapods_FirebaseAuth3_FIRAuthErrorDomain_getter )
  "_OBJC_CLASS_$_FIRUser", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRMultiFactorSession", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRPhoneAuthProvider", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRAuthDataResult", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRGoogleAuthProvider", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRMultiFactorInfo", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIREmailAuthProvider", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRGitHubAuthProvider", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRFacebookAuthProvider", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRActionCodeSettings", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRTwitterAuthProvider", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRAuth", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIROAuthProvider", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIROptions", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRActionCodeInfo", referenced from:
      objc-class-ref in shared(result.o)
  "_OBJC_CLASS_$_FIRApp", referenced from:
      objc-class-ref in shared(result.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I noticed that, when cloning the firebase-kotlin-sdk repository and trying to build firebase-auth from there, there’s an additional Carthage step which seems to download the required frameworks and link them: *** Downloading binary-only framework FirebaseAuthBinary at "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json"

… but this step doesn’t seem to happen when using dev.gitlive:firebase-auth:1.0.0 as a dependency. Is there a way to solve this issue? Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Daeda88commented, Dec 6, 2020

sorry, forgot about that part. Add a Cartfile ${rootProject.projectDir}/ios/ containing the required Firebase dependencies: binary “https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json” == 6.30.0 binary “https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json” == 6.30.0 binary “https://dl.google.com/dl/firebase/ios/carthage/FirebaseFirestoreBinary.json” == 6.30.0 binary “https://dl.google.com/dl/firebase/ios/carthage/FirebaseFunctionsBinary.json” == 6.30.0

1reaction
Daeda88commented, Dec 4, 2020

I think currently the library doesnt export Firebase to projects implementing it. It just tells Xcode to import the library. To add it, in your build.gradle:

kotlin {
    ios {
        binaries {
            framework {
                isStatic = false
                transitiveExport = true

                linkerOpts("-F${rootProject.projectDir}/ios/Carthage/Build/iOS/")
                linkerOpts("-ObjC")
            }
            getTest("DEBUG").apply {
                linkerOpts("-F${rootProject.projectDir}/ios/Carthage/Build/iOS/")
                linkerOpts("-ObjC")
            }
        }
    }
   ...
   tasks {
        listOf("bootstrap", "update").forEach {
            task<Exec>("carthage${it.capitalize()}") {
                group = "carthage"
                executable = "carthage"
                args(
                    it,
                    "--project-directory", "${rootProject.projectDir}/ios/",
                    "--platform", "iOS",
                    "--cache-builds"
                )
            }
        }
    }
}

afterEvaluate {
    tasks.named("linkDebugTestIosArm64").configure {
        dependsOn(tasks.named("carthageBootstrap"))
    }
    tasks.named("linkDebugTestIosX64").configure {
        dependsOn(tasks.named("carthageBootstrap"))
    }
    tasks.named("linkDebugFrameworkIosArm64").configure {
        dependsOn(tasks.named("carthageBootstrap"))
    }
    tasks.named("linkDebugFrameworkIosX64").configure {
        dependsOn(tasks.named("carthageBootstrap"))
    }
    tasks.named("linkReleaseFrameworkIosArm64").configure {
        dependsOn(tasks.named("carthageBootstrap"))
    }
    tasks.named("linkReleaseFrameworkIosX64").configure {
        dependsOn(tasks.named("carthageBootstrap"))
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Apple Mach-O Linker Error | Apple Developer Forums
Hello together, im new in this forum. I just have some problem to test one of my apps. As soon as i press...
Read more >
Linker errors when building with Xcode 12 and CocoaPods ...
Xcode 12 raises linker errors about architectures when building the navigation SDK using CocoaPods. These warnings also cause CocoaPods to ...
Read more >
Linker errors when building for release on iOS - Airship Support
Linker errors like that could come as a result of an incorrect implementation of the SDK, or some configuration issues. The two things...
Read more >
Ionic app linker errors after building for iOS - Stack Overflow
I am developing an app using the Ionic 4 framework and am currently attempting to build it for iOS and release it to...
Read more >
Linking Errors Building For iOS. All latest versions. - Unity Forum
I'm encountering this error right now after attempting to build a spectatorview app for iPhone (from Mixed Reality Toolkit). I'm not very ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found