firebase-kotlin-sdk
firebase-kotlin-sdk copied to clipboard
Cannot build iOS app: framework not found FirebaseFirestore
Hi, I am trying to integrate FirebaseFirestore, like this:
sourceSets {
val commonMain by getting {
dependencies {
...
implementation("dev.gitlive:firebase-firestore:1.4.3")
}
}
I am using new KMM project from IDE wizard with iOS and Android modules for apps, and shared module for common code.
And when I am trying to build iOS app I am getting this error:
Task :shared:linkDebugFrameworkIos FAILED e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1. output: ld: framework not found FirebaseFirestore
Any pointer about how to debug this would be helpful. Thanks
This is what I had to do for SDK in env. For Carthage and CocoaPods there are other solutions available:
`val xcf = XCFramework() val libs = listOf( "FirebaseAuth.xcframework", "GTMSessionFetcher.xcframework", "FirebaseCore.xcframework", "FirebaseCoreDiagnostics.xcframework", "FirebaseAnalytics.xcframework", "GoogleAppMeasurement.xcframework", "FirebaseInstallations.xcframework", "GoogleDataTransport.xcframework", "GoogleUtilities.xcframework", "PromisesObjC.xcframework", "nanopb.xcframework", "FirebaseFunctions.xcframework" ) val nativeFrameworkPaths = projectDir.resolve(System.getenv("FIREBASE_SDK")).listFiles() .filter { it.isDirectory } .flatMap { it.listFiles().filter { it.isDirectory && libs.contains(it.name) } }
ios()
iosArm64 {
binaries.framework {
baseName = "Module"
xcf.add(this)
val libraryIdentifier = "ios-arm64_armv7"
linkerOpts(nativeFrameworkPaths.map { "-F$it/$libraryIdentifier" })
linkerOpts("-ObjC")
}
}
val iosSims = listOf(iosX64(), iosSimulatorArm64())
configure(iosSims) {
binaries.framework {
baseName = "Module"
xcf.add(this)
val libraryIdentifier = "ios-arm64_i386_x86_64-simulator"
linkerOpts(nativeFrameworkPaths.map { "-F$it/$libraryIdentifier" })
linkerOpts("-ObjC")
}
}
} `
Hello, I have tried this solution but I have gotten this error
System.getenv("FIREBASE_SDK") must not be null
at org.gradle.kotlin.dsl.execution.InterpreterKt$locationAwareExceptionFor$2.invoke(Interpreter.kt:563)
at org.gradle.kotlin.dsl.execution.InterpreterKt.locationAwareExceptionFor(Interpreter.kt:570)
at org.gradle.kotlin.dsl.execution.InterpreterKt.locationAwareExceptionHandlingFor(Interpreter.kt:536)
at org.gradle.kotlin.dsl.execution.InterpreterKt.access$locationAwareExceptionHandlingFor(Interpreter.kt:1)
at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.handleScriptException(Interpreter.kt:385)
- Download Firebase as a zip file: https://firebase.google.com/docs/ios/setup#frameworks
- Unzip
- Set env variable FIREBASE_SDK to point where you unzipped it e.g.
export FIREBASE_SDK=~/Downloads/Firebase
Why does the project using this library need to download Firebase SDK?
I thought it should come with this library - or as a transitive dependency of the library.
What is the meaning of the cart files then? https://github.com/GitLiveApp/firebase-kotlin-sdk/blob/master/firebase-functions/src/nativeInterop/cinterop/Cartfile
There are generally four ways of having dependencies in an Xcode project:
- cocoapods
- Carthage
- SPM
- File system
my example uses file system through an env variable. Unfortunately I can’t help you with the others.
Looks like it makes sense to provide a sample for library users, to showcase iOS setup. Me myself is still struggling to find the best way to link iOS Firebase frameworks to KMM. @nbransby @Reedyuk tagging you just in case you can help here.
For what it's worth, my iOS setup is working fine out of the box if I add Firebase/Firestore
as a Cocoapods dependency (even directly in the Podfile which Kotlin doesn't know about, not in the gradle cocoapods {}
config).
For what it's worth, my iOS setup is working fine out of the box if I add
Firebase/Firestore
as a Cocoapods dependency (even directly in the Podfile which Kotlin doesn't know about, not in the gradlecocoapods {}
config).
Same
@walkingbrad I have a similar issue with remote-config requiring "firebaseABTesting", but just adding that as a pod results in Cinterop issues
Failed to generate cinterop for :mcdonalds-umbrella-module:cinteropFirebaseABTestingIosArm64: Process 'command '/Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java'' finished with non-zero exit value 134
Exception in thread "Thread-3" kotlin.NotImplementedError: An operation is not implemented: support enum forward declarations: enum ABTExperimentPayloadExperimentOverflowPolicy
at org.jetbrains.kotlin.native.interop.indexer.NativeIndexImpl.getEnumDefAt(Indexer.kt:321)
at org.jetbrains.kotlin.native.interop.indexer.NativeIndexImpl.indexDeclaration(Indexer.kt:877)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt$indexDeclarations$1$2.indexDeclaration(Indexer.kt:1208)
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt$indexTranslationUnit$1$indexerCallbacks$1$4.invoke(Utils.kt:561)
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt$indexTranslationUnit$1$indexerCallbacks$1$4.invoke(Utils.kt:558)
at kotlinx.cinterop.JvmCallbacksKt$createStaticCFunctionImpl$$inlined$ffiClosureImpl$3.accept(JvmCallbacks.kt:510)
I'm having the same issue with "FirebaseABTesting". I'm using Swift Package Manager.
I am also facing the same issue. I've tried adding the dependency manually:
- Using SPM
- Cocoapods (which told me that the dependency already existed if I added via Gradle and it simply didn't work if independent)
- Carthage (although I might not have set it correctly since I am not very familiar with it).
But I always end up having the same error 🥲
The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
ld: framework not found FirebaseAuth
Could someone provide a sample/guide/gist on how to configure the build.gradle
so that we can use FirebaseFirestore
or any other dependency in common code and target iOS?
I've tried to follow #111 #208 #322 #326 with no luck 🥲. @casvanluijtelaar created a minimum reproducible example here https://github.com/GitLiveApp/firebase-kotlin-sdk/issues/326#issuecomment-1285496883, not sure if anyone has been able to check it.
Any help would be greatly appreciated 🙇🏻♂️
Hello there, I face the same issue
ld: framework not found FirebaseABTesting
Task :shared:linkReleaseFrameworkIosX64 FAILED
Are there any plans to release a new version soon as I see it uses kotlin 1.6.10 and version 1.8 is around the corner. Thanks in advance for any replay.
I resolved the issue and made a sample project: https://github.com/leoull/KMM-FirebaseAuth
Can you guys try release 1.8.0, the switch over to cocoapods plugin should make the resolution easier
thanks for the update @Reedyuk! i solved the issue last time by creating a new project from scratch and selecting cooapods from the kmm plugin setup wizard. not sure why the default framework option + setting cocoapods myself for this was not working (i guess i was setting up something wrong)
the new update seems to be working well, but i don't know if it would have helped back when i was stuck. thanks for the update and keeping this repo alive!
setting isStatic = true
in build.gradle fixed this