8

I'm trying to use cocoapods framework in Kotlin Multiplatform project. So I

  • added framework to Pods file.
  • ran pod install.
  • created .def file
  • added cinterop config in build.gradle

./gradlew cinteropFirebaseIos runs successfully. It generates .klib so I can see classes in kotlin code. But when I'm trying to run iOS app build fails with message:

Showing Recent Messages

> Task :app:linkDebugFrameworkIos

ld: framework not found FirebaseDatabase

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors

Here is my config in build.gradle

    fromPreset(presets.iosX64, 'ios') {
        compilations.main {
            outputKinds('FRAMEWORK')
            cinterops {
                firebase {
                    def proj = "${System.getProperty("user.home")}/Projects/kmpp"
                    def pods = "${proj}/iosApp/Pods"

                    defFile "${proj}/app/src/iosMain/c_interop/libfirebase.def"

                    includeDirs "${pods}/Firebase",
                            "${pods}/Firebase/CoreOnly/Sources",
                            "${pods}/FirebaseAnalytics/Frameworks/FirebaseAnalytics.framework/Headers"
                }
            }
        }
    }

here is my .def file:

language = Objective-C
headers = /Users/oleg/Projects/klug/crckalculator/iosApp/Pods/FirebaseCore/Firebase/Core/Public/FIRApp.h /Users/oleg/Projects/klug/crckalculator/iosApp/Pods/FirebaseDatabase/Firebase/Database/Public/FIRDatabase.h /Users/oleg/Projects/klug/crckalculator/iosApp/Pods/FirebaseCore/Firebase/Core/Public/FirebaseCore.h

compilerOpts = -framework FirebaseDatabase
linkerOpts = -framework FirebaseDatabase

enter image description here

How can I figure out what is wrong ? Did I miss something in .def file ? In build.gradle ?

Community
  • 1
  • 1
oleg.semen
  • 2,901
  • 2
  • 28
  • 56

1 Answers1

1

There are two problematic moments here:

Nikolay Igotti
  • 580
  • 2
  • 7
  • Thanks @Nikolay. Regarding full path to headers it's quite obvious, I've been trying to do this but it could not resolve imports. For instance `Firebase.h` starts with `#import ` but `FirebaseCore.h` placed under `iosApp/Pods/FirebaseCore/Firebase/Core/Public/` folder. – oleg.semen Jan 06 '19 at 01:30
  • Another quite strange thing is that `FIRAnalyticsConnector.framework`, `FirebaseAnalytics.framework`, `FirebaseCoreDiagnostics.framework`, `FirebaseInstanceID.framework` and `GoogleAppMeasurement.framework` in my `Pods` folder although I did not install these pods. `FirebaseDatabase.framework` I found in `/Users/oleg/Library/Developer/Xcode/DerivedData/iosApp-dhmxgbkvemesnaamasxaqqyuqyox/Build/Products/Debug-iphonesimulator/FirebaseDatabase/` folder. Now when I'm specifying this framework I'm getting some `Undefined symbols for architecture x86_64:` errors (there are quite a few of them). – oleg.semen Jan 06 '19 at 01:37
  • BTW there are `linkerOpts` in both `.gradle` and `.def` files. Are they the same ? – oleg.semen Jan 06 '19 at 01:39
  • One more question: What about transitive dependencies ? Firebase consists of few libs/frameworks like Core, Database, Firestore, Messaging etc. They depend on each other. Is it enough to specify one of them I'm using ? Or should I specify all of them ? – oleg.semen Jan 06 '19 at 01:44
  • Linker options from .def and Gradle pluginare concatenated essentially. – Nikolay Igotti Jan 07 '19 at 09:49