Tried to use the kotlin native cocoapod gradle plugin. But it produces the error below whenever sqldelight is included as a dependency.
Undefined symbols for architecture arm64:
"_sqlite3_bind_text16", referenced from:
_SQLiter_SQLiteStatement_nativeBindString in app(combined.o)
"_sqlite3_bind_int64", referenced from:
_SQLiter_SQLiteStatement_nativeBindLong in app(combined.o)
"_sqlite3_last_insert_rowid", referenced from:
_SQLiter_SQLiteStatement_nativeExecuteForLastInsertedRowId in app(combined.o)
"_sqlite3_reset", referenced from:
_SQLiter_SQLiteConnection_nativeResetStatement in app(combined.o)
"_sqlite3_changes", referenced from:
_SQLiter_SQLiteStatement_nativeExecuteForChangedRowCount in app(combined.o)
_SQLiter_SQLiteStatement_nativeExecuteForLastInsertedRowId in app(combined.o)
"_sqlite3_open_v2", referenced from:
_SQLiter_SQLiteConnection_nativeOpen in app(combined.o)
"_sqlite3_db_config", referenced from:
_SQLiter_SQLiteConnection_nativeOpen in app(combined.o)
"_sqlite3_busy_timeout", referenced from:
_SQLiter_SQLiteConnection_nativeOpen in app(combined.o)
"_sqlite3_trace", referenced from:
_SQLiter_SQLiteConnection_nativeOpen in app(combined.o)
"_sqlite3_bind_parameter_index", referenced from:
_SQLiter_SQLiteConnection_nativeBindParameterIndex in app(combined.o)
"_sqlite3_column_bytes", referenced from:
_SQLiter_SQLiteConnection_nativeColumnGetString in app(combined.o)
_SQLiter_SQLiteConnection_nativeColumnGetBlob in app(combined.o)
"_sqlite3_finalize", referenced from:
_SQLiter_SQLiteStatement_nativeFinalizeStatement in app(combined.o)
"_sqlite3_column_text", referenced from:
_SQLiter_SQLiteConnection_nativeColumnGetString in app(combined.o)
"_sqlite3_column_name", referenced from:
_SQLiter_SQLiteConnection_nativeColumnName in app(combined.o)
"_sqlite3_bind_double", referenced from:
_SQLiter_SQLiteStatement_nativeBindDouble in app(combined.o)
"_sqlite3_profile", referenced from:
_SQLiter_SQLiteConnection_nativeOpen in app(combined.o)
"_sqlite3_close", referenced from:
_SQLiter_SQLiteConnection_nativeClose in app(combined.o)
_SQLiter_SQLiteConnection_nativeOpen in app(combined.o)
"_sqlite3_prepare16_v2", referenced from:
_SQLiter_SQLiteConnection_nativePrepareStatement in app(combined.o)
"_sqlite3_column_type", referenced from:
_SQLiter_SQLiteConnection_nativeColumnIsNull in app(combined.o)
_SQLiter_SQLiteConnection_nativeColumnType in app(combined.o)
"_sqlite3_column_count", referenced from:
_SQLiter_SQLiteConnection_nativeColumnCount in app(combined.o)
"_sqlite3_bind_blob", referenced from:
_SQLiter_SQLiteStatement_nativeBindBlob in app(combined.o)
"_sqlite3_db_readonly", referenced from:
_SQLiter_SQLiteConnection_nativeOpen in app(combined.o)
"_sqlite3_column_int64", referenced from:
_SQLiter_SQLiteConnection_nativeColumnGetLong in app(combined.o)
"_sqlite3_bind_null", referenced from:
_SQLiter_SQLiteStatement_nativeBindNull in app(combined.o)
"_sqlite3_extended_errcode", referenced from:
android::throw_sqlite3_exception(sqlite3) in app(combined.o)
android::throw_sqlite3_exception(sqlite3, char const) in app(combined.o)
"_sqlite3_column_double", referenced from:
_SQLiter_SQLiteConnection_nativeColumnGetDouble in app(combined.o)
"_sqlite3_column_blob", referenced from:
_SQLiter_SQLiteConnection_nativeColumnGetBlob in app(combined.o)
"_sqlite3_step", referenced from:
_SQLiter_SQLiteConnection_nativeStep in app(combined.o)
_SQLiter_SQLiteStatement_nativeExecute in app(combined.o)
_SQLiter_SQLiteStatement_nativeExecuteForChangedRowCount in app(combined.o)
_SQLiter_SQLiteStatement_nativeExecuteForLastInsertedRowId in app(combined.o)
"_sqlite3_clear_bindings", referenced from:
_SQLiter_SQLiteConnection_nativeClearBindings in app(combined.o)
"_sqlite3_errmsg", referenced from:
android::throw_sqlite3_exception(sqlite3) in app(combined.o)
android::throw_sqlite3_exception(sqlite3, char const) in app(combined.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
In xcode, you need to add -lsqlite3 to Other Liker Flags in your Bulid Settings. I generally get that from other included Pods, but it depends what you're using.

Hi,
i have the same problem when build with gradlew assemble, any suggestion?
thanks
Stack trace?
Undefined symbols for architecture x86_64:
"_sqlite3_bind_blob", referenced from:
_SQLiter_SQLiteStatement_nativeBindBlob in result.o
"_sqlite3_bind_double", referenced from:
_SQLiter_SQLiteStatement_nativeBindDouble in result.o
"_sqlite3_bind_int64", referenced from:
_SQLiter_SQLiteStatement_nativeBindLong in result.o
"_sqlite3_bind_null", referenced from:
_SQLiter_SQLiteStatement_nativeBindNull in result.o
"_sqlite3_bind_parameter_index", referenced from:
_SQLiter_SQLiteConnection_nativeBindParameterIndex in result.o
"_sqlite3_bind_text16", referenced from:
_SQLiter_SQLiteStatement_nativeBindString in result.o
"_sqlite3_busy_timeout", referenced from:
_SQLiter_SQLiteConnection_nativeOpen in result.o
"_sqlite3_changes", referenced from:
_SQLiter_SQLiteStatement_nativeExecuteForChangedRowCount in result.o
_SQLiter_SQLiteStatement_nativeExecuteForLastInsertedRowId in result.o
"_sqlite3_clear_bindings", referenced from:
_SQLiter_SQLiteConnection_nativeClearBindings in result.o
"_sqlite3_close", referenced from:
_SQLiter_SQLiteConnection_nativeClose in result.o
_SQLiter_SQLiteConnection_nativeOpen in result.o
"_sqlite3_column_blob", referenced from:
_SQLiter_SQLiteConnection_nativeColumnGetBlob in result.o
"_sqlite3_column_bytes", referenced from:
_SQLiter_SQLiteConnection_nativeColumnGetString in result.o
_SQLiter_SQLiteConnection_nativeColumnGetBlob in result.o
"_sqlite3_column_count", referenced from:
_SQLiter_SQLiteConnection_nativeColumnCount in result.o
"_sqlite3_column_double", referenced from:
_SQLiter_SQLiteConnection_nativeColumnGetDouble in result.o
"_sqlite3_column_int64", referenced from:
_SQLiter_SQLiteConnection_nativeColumnGetLong in result.o
..
..
"_sqlite3_step", referenced from:
_SQLiter_SQLiteConnection_nativeStep in result.o
_SQLiter_SQLiteStatement_nativeExecute in result.o
_SQLiter_SQLiteStatement_nativeExecuteForChangedRowCount in result.o
_SQLiter_SQLiteStatement_nativeExecuteForLastInsertedRowId in result.o
"_sqlite3_trace", referenced from:
_SQLiter_SQLiteConnection_nativeOpen in result.o
ld: symbol(s) not found for architecture x86_64
e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
In the gradle i have:
compilations.each {
it.extraOpts("-linker-options", "-lsqlite3")
}
@alfdev where exactly do you have it? do you have some example?
I have the same problem when I use the Cocoapods plugin. The workaround from kpgalligan (setting the linker options in Xcode) is working but setting the linker options in gradle seems to have no effect.
Am I doing something wrong here?
val isDevice = System.getenv("SDK_NAME")?.startsWith("iphoneos") == true
if (isDevice)
iosArm64("ios")
else
iosX64("ios")
targets.getByName<KotlinNativeTarget>("ios").compilations.forEach {
it.kotlinOptions.freeCompilerArgs += arrayOf("-linker-options", "-lsqlite3")
}
Also I found this issue https://github.com/JetBrains/kotlin-native/issues/3672 . Does anyone know if “extraOpts” or “compilerArgs” work with the Cocoapods plugin in general ?
The linker option in Xcode isn't a workaround. That's when Xcode is linking
your kotlin code with the rest of the iOS code, and it needs to explicitly
link to sqlite3. You'll also need to do that in gradle if running tests,
because that's building an executable without an explicit Xcode project.
On Sun, Mar 29, 2020 at 8:18 AM Fabian notifications@github.com wrote:
I have the same problem when I use the Cocoapods plugin. The workaround
from kpgalligan (setting the linker options in Xcode) is working but
setting the linker options in gradle seems to have no effect.Am I doing something wrong here?
val isDevice = System.getenv("SDK_NAME")?.startsWith("iphoneos") == true
if (isDevice)
iosArm64("ios")
else
iosX64("ios")
targets.getByName
("ios").compilations.forEach { it.kotlinOptions.freeCompilerArgs += arrayOf("-linker-options", "-lsqlite3")
}
Also I found this issue JetBrains/kotlin-native#3672
https://github.com/JetBrains/kotlin-native/issues/3672 . Does anyone
know if “extraOpts” or “compilerArgs” work with the Cocoapods plugin in
general ?—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/cashapp/sqldelight/issues/1442#issuecomment-605627452,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAQWICSXJANRGBECOSTZRTRJ44CTANCNFSM4IOB6XDA
.
--
Kevin Galligan
https://twitter.com/kpgalligan
@HFabi I ran into the same issue although I'm not using the Cocoapods plugin but the packForXCode gradle taks as in the Kotlin MPP for Android-iOS example and then linking the produced framework directly in Xcode. I was able to fix the issue by adding the linker options as follows:
OSTarget("ios") {
binaries {
framework {
baseName = "sharedDatabase"
linkerOpts.add("-lsqlite3")
}
}
}
Maybe adding the linker options to the binaries may help in your case, too.
targets.getByName<KotlinNativeTarget>("ios").binaries.forEach {
it.linkerOpts.add("-lsqlite3")
}
@HFabi I ran into the same issue although I'm not using the Cocoapods plugin but the packForXCode gradle taks as in the Kotlin MPP for Android-iOS example and then linking the produced framework directly in Xcode. I was able to fix the issue by adding the linker options as follows:
OSTarget("ios") { binaries { framework { baseName = "sharedDatabase" linkerOpts.add("-lsqlite3") } } }Maybe adding the linker options to the binaries may help in your case, too.
targets.getByName<KotlinNativeTarget>("ios").binaries.forEach { it.linkerOpts.add("-lsqlite3") }
Hello, I try to add linkerOpts.add("-lsqlite3")
But I have this problem :
> Could not get unknown property 'linkerOpts' for object of type org.jetbrains.kotlin.gradle.dsl.KotlinNativeBinaryContainer.
This is my build.gradle :
targets {
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") ? presets.iosArm64 : presets.iosX64
fromPreset(iOSTarget, 'ios') {
binaries {
framework('iosFramework') // nom du framework
}
}
}
@Yeeeeeeah before I switched to the cocoapods plugin, I also used the packForXCode approach from the tutorial. There I could set linkSqlite = true, perhaps that solves your problem.
// build.gradle.kts
sqldelight {
database("...") {
// ...
}
linkSqlite = true // <-
}
Adding -lsqlite3 to Other Liker Flags in your Bulid Settings like @kpgalligan suggested worked for me.
But I also got it working with the cocoapods plugin using a dynamic library with the linker option added:
targets.filterIsInstance<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>().forEach{
it.binaries.filterIsInstance<org.jetbrains.kotlin.gradle.plugin.mpp.Framework>()
.forEach { lib ->
lib.isStatic = false
lib.linkerOpts.add("-lsqlite3")
}
}
Referenced:
https://github.com/JetBrains/kotlin-native/issues/3059#issuecomment-577041551
Most helpful comment
In xcode, you need to add
-lsqlite3toOther Liker Flagsin yourBulid Settings. I generally get that from other included Pods, but it depends what you're using.