Hi <@U01A4RQ9XGW> VertexSample (KMP App Project) ...
# multiplatform
s
Hi @Andrey Yastrebov VertexSample (KMP App Project) imports firebase-ai-kmp via gradle mavenLocal: https://github.com/SeanChinJunKai/VertexSample firebase-ai-kmp (KMP Library) imports FireabaseAIBridge via cocoapods: https://github.com/SeanChinJunKai/firebase-ai-kmp FirebaseAIBridge is a static library (XCode Project) with swift code annotated with @objc: https://github.com/SeanChinJunKai/FirebaseAIBridge I get the following errors when trying to build the iOS app in VertexSample ld: warning: search path '/Users/seanchin/VertexSample/shared/build/xcode-frameworks/Debug/iphonesimulator18.4' not found ld: warning: Could not find or use auto-linked framework 'FirebaseAIBridge': framework 'FirebaseAIBridge' not found ld: warning: Could not parse or use implicit file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore.tbd': cannot link directly with 'SwiftUICore' because product being built is not an allowed client of it Undefined symbols for architecture arm64: "_OBJC_CLASS_$_FileDataPartObjc", referenced from: in ComposeApp[2810](libio.github.seanchinjunkai:firebase-ai-kmp-cache.a.o) "_OBJC_CLASS_$_FirebaseObjc", referenced from: in ComposeApp[2810](libio.github.seanchinjunkai:firebase-ai-kmp-cache.a.o) "_OBJC_CLASS_$_ImagePartObjc", referenced from: in ComposeApp[2810](libio.github.seanchinjunkai:firebase-ai-kmp-cache.a.o) "_OBJC_CLASS_$_InlineDataPartObjc", referenced from: in ComposeApp[2810](libio.github.seanchinjunkai:firebase-ai-kmp-cache.a.o) "_OBJC_CLASS_$_TextPartObjc", referenced from: in ComposeApp[2810](libio.github.seanchinjunkai:firebase-ai-kmp-cache.a.o) ld: symbol(s) not found for architecture arm64
🧵 1
I removed isStatic = True and the undefined symbols went away but im getting: ld: warning: ignoring duplicate libraries: '-ldl' ld: framework 'FirebaseAIBridge' not found
Task composeApplinkDebugFrameworkIosSimulatorArm64 FAILED
error: Compilation finished with errors I suspect that it is because of the following declaration in the kmp library
Copy code
cocoapods {
    ios.deploymentTarget = libs.versions.ios.deploymentTarget.get()
    framework {
        baseName = "FirebaseAI" // Not FirebaseAIBridge due to ld: can't link a dylib with itself. same install_name as dylib being built
    }
    pod("FirebaseAIBridge") {
        source = git("<https://github.com/SeanChinJunKai/FirebaseAIBridge>") {
            branch = "main"
        }
        extraOpts += listOf("-compiler-option", "-fmodules")
    }
}
a
Hi @Sean Chin Jun Kai I don't see any cocoapods imports here: https://github.com/SeanChinJunKai/firebase-ai-kmp Take a look at our sample as a reference, it has similar setup: https://github.com/Kotlin/kmp-with-cocoapods-compose-sample
s
oh sorry the cocoapods import is on the draft/sean branch for the firebase-ai-kmp and using the cocoapods kotlin plugin
i was wondering if it’s possible to not use cocoapods in the kmp app and just importing the library via gradle would be sufficient
a
You shouldn't mix direct integration and cocoapods integration. I also don't think you really need firebase-ai-kmp here, you can attach FirebaseAIBridge directly to your project
s
firebase ai kmp supports android and ios so i’m hoping that users can just directly import it in their kmp as gradle dependency. there is expect actual declaration in firebase ai kmp
a
The users still need to link against the FirebaseAIBridge, otherwise it won't work. Please take a look at the sample: https://github.com/Kotlin/kmp-with-cocoapods-compose-sample
s
ohhh okay thanks for sharing
would users still have to link if i’m using cinterop tool instead of cocoapods in the firebase-ai-kmp ?
a
yes
s
thank you so much @Andrey Yastrebov
im trying to add the plugin but i keep getting this error and i am unable to declare cocoapods block Cocoapods Integration requires pod version to be specified. Please specify pod version by adding 'version = "version"' to the cocoapods block. Alternatively, specify the version for the entire project explicitly. Pod version format has to conform podspec syntax requirements: https://guides.cocoapods.org/syntax/podspec.html#version
a
just declare a version like:
version = "1.0"
👍 1
s
Ive taken a look at the sample. I am not pushing the pods to trunk but i am getting from my github repo like this
Copy code
cocoapods {
    version = "1.0"

    podfile = project.file("../iosApp/Podfile")
    summary = "Sample App demonstrating firebase-ai-kmp sdk"
    homepage = "<https://github.com/SeanChinJunKai>"
    license = "Apache-2.0"

    ios.deploymentTarget = libs.versions.ios.deploymentTarget.get()


    pod("FirebaseAIBridge") {
        source = git("<https://github.com/SeanChinJunKai/FirebaseAIBridge>") {
            branch = "main"
        }
        linkOnly = true
        extraOpts += listOf("-compiler-option", "-fmodules")
    }


    framework {
        baseName = "ComposeApp"
        isStatic = true
    }
}
and this is my iosApp podfile
Copy code
source '<https://cdn.cocoapods.org>'
deployment_target = '15.0'

target 'iosApp' do
  use_frameworks!
  platform :ios, deployment_target
  # Pods for iosApp
  pod 'FirebaseAIBridge', :git => '<https://github.com/SeanChinJunKai/FirebaseAIBridge>', :branch => 'main'
  pod 'composeApp', :path => '../composeApp'
end
but im still getting the below error: The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1. output: ld: warning: ignoring duplicate libraries: '-ldl' ld: framework 'FirebaseAIBridge' not found error: Compilation finished with errors FAILURE: Build failed with an exception.
a
Can you attach a reproducer project?
s
you can refer to this project: https://github.com/SeanChinJunKai/VertexSample
a
I'll take a closer look tomorrow
s
thank you so much @Andrey Yastrebov
@Andrey Yastrebov do let me know if there are any more details which you require
a
1. Remove spm firebase dependency from your project 2. Remove
Compile Kotlin Framework
build phase from your project 3. remove this, since you are using cocoapods integration
Copy code
listOf(
        iosArm64(),
        iosSimulatorArm64()
    ).forEach { iosTarget ->
        iosTarget.binaries.framework {
            baseName = "ComposeApp"
            binaryOption("bundleId", "com.seanchinjunkai.VertexSample")
        }
    }
I still don't see any cocoapods dependency in your lib
Here is a fixed sample, you need to add missing GoogleService-Info.plist
And again I recommend you carefully follow the sample project: https://github.com/Kotlin/kmp-with-cocoapods-compose-sample
s
sorry the readme is misleading
i have added the google info plist in my repo its not on github due to leaked keys
ill try the above