Comments (9)
So I went spelunking around in the SQLDelight gradle plugin source to see if I could find how adding the plugin to my shared project solved the linking problem. Then I thought I could just pull that out and use it, avoiding the other problems the plugin was causing. Well, I found it and it worked!
If I add this to my shared build.gradle.kts
file right below the android
block, all methods of building work, and the above workarounds are no longer necessary:
fun Project.linkSqlite() {
val extension = project.extensions.findByType(org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension::class.java) ?: return
extension.targets
.filterIsInstance<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget>()
.flatMap { it.binaries }
.forEach { compilationUnit ->
compilationUnit.linkerOpts("-lsqlite3")
}
}
linkSqlite()
This is a literal cut-and-paste. I'm not a gradle expert and I haven't done anything to clean it up yet. But this is my fourth attempt over many months of trying to get this to work, so I'm happy to finally have a solution.
After some minor clean-up:
project.extensions.findByType(KotlinMultiplatformExtension::class.java)?.apply {
targets
.filterIsInstance<KotlinNativeTarget>()
.flatMap { it.binaries }
.forEach { compilationUnit -> compilationUnit.linkerOpts("-lsqlite3") }
}
from sqliter.
Need to add the sqlite linker arg -lsqlite3
. See long thread discussing: cashapp/sqldelight#1442 (comment)
from sqliter.
I've tried:
kotlin {
[
iosX64(),
iosArm64(),
iosSimulatorArm64(),
].forEach {
it.binaries.all {
freeCompilerArgs += "-Xg0" // Required for CrashKiOS.
if (it instanceof org.jetbrains.kotlin.gradle.plugin.mpp.Framework) {
it.isStatic = true // Required for CrashKiOS.
it.linkerOpts.add("-lsqlite3")
it.embedBitcode("YES".equals(System.getenv("ENABLE_BITCODE")) ? "bitcode" : "marker")
it.setFreeCompilerArgs(it.getFreeCompilerArgs() + "-Xobjc-generics")
}
}
}
}
Does not seem to do the trick though.
from sqliter.
Sorry for delay here. Was this resolved? Will take a look on newer sqldelight releases if not. At the end of the day, it's always some form of -lsqlite3
is missing somewhere, but occasionally it's in an unexpected place.
from sqliter.
Nope. Still getting that failure.
from sqliter.
@vanniktech did you find a fix? I'm facing a similar issue and I've tried all possible linking solutions and am still unable to run ./gradlew iosSimulatorArm64Test
I have a shared
module that contains database stuff and shared-ui
for presentation logic that exports shared
. I can run ./gradlew :shared:iosSimulatorArm64Test
and it works, however when trying to run shared-ui
tests it fails.
from sqliter.
Nope. I have the exact same issue as you do.
from sqliter.
I have the same problem. I also have a separate module for database stuff. I've found that if I add the sqldelight plugin to both modules while keeping the sqldelight configuration block only in the database module, everything compiles and links properly, but I lose the on-the-fly code generation and other niceties sqldelight provides.
from sqliter.
Closing this. Please re-open and let us know if you're still having issues
from sqliter.
Related Issues (20)
- Database file name being created duplicates the last two characters
- Exclude DB from backup/icloud (iOS) HOT 2
- `create` callback invoked only on first connection for in-memory/temporary DBs
- Fix windows and linux builds HOT 3
- Maven coordinate change in 1.3.0 HOT 3
- Add support for androidNative
- Update Kotlin version: 1.9.20 -> 1.9.21
- any docs? HOT 1
- Flaky watchOS test
- Pull error message from sqlite anywhere we have a failure HOT 1
- Review logging
- Kotlin 1.7.20 compatible aarch64 artifacts HOT 2
- SQLiter - 1.8 Beta Testing HOT 6
- SQliter - 1.8 Release Testing HOT 1
- Documentation references
- The encryption part is not working properly HOT 10
- Support calling `sqlite3_create_collation`
- Cannot run tests on macOS
- in memory DB is not thread-safe
- Support linuxArm64
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqliter.