cashapp / sqldelight

SQLDelight - Generates typesafe Kotlin APIs from SQL
https://cashapp.github.io/sqldelight/
Apache License 2.0
6.15k stars 516 forks source link

Update from 1.5.3 to 1.5.4 breaks building of AppDatabase for kotlin native #3592

Open wman1980 opened 1 year ago

wman1980 commented 1 year ago

SQLDelight Version

1.5.4

Operating System

macOS Montgomery 12.6

Gradle Version

7.3.0

Kotlin Version

1.7.20

Dialect

SQLite

AGP Version

No response

Describe the Bug

Hi, I am using KMM (Kotlin Multiplatform Mobile) to build iOS and Android Apps with a shared code base.

Currently I have updated all multiplatform library dependencies like kTor, serialisationX, dateTimeX and sqldelight to the latest versions.

Unfortunately it seems that updating from sqldelight 1.5.3 to 1.5.4 breaks building my AppDatabase. All other multiplatform libraries could be updated.

For my shared code I defined the AppDatabase as followed:

sqldelight {
    database("AppDatabase") {
        packageName = "foo.bar.cache"
    }
}

After I have changed the sqldelight version to 1.5.4 it seems that the AppDatabase is not generated anymore for my iOS target and I get the following error while building:

Unresolved reference: AppDatabase

If I switch back to 1.5.3 everything is working again. Is that a known issue?

Thanks Jan

Stacktrace

No response

Gradle Build Script

No response

StefanOltmann commented 1 year ago

I have the same problem.

I also got this message before the error mentioned in this post:


> Task :shared:compileAppleMainKotlinMetadata FAILED
w: Could not find "co.touchlab:sqliter-driver-cinterop-sqlite3" in [/Users/sol/IdeaProjects/myapp, /Users/stefan/.konan/klib, /Users/stefan/.konan/kotlin-native-prebuilt-macos-aarch64-1.7.20/klib/common, /Users/stefan/.konan/kotlin-native-prebuilt-macos-aarch64-1.7.20/klib/platform/ios_arm64]
AlecKazakova commented 1 year ago

hmm....yea maybe an issue wuth there not being a 1.7.20 compatible sqliter artifact?

wman1980 commented 1 year ago

Hi @AlecStrong, is that something we can fix on our site?

I just had a look at the documentation (https://cashapp.github.io/sqldelight/native_sqlite/) and it looks like that there is not much we can do from our site.

Anyway I think its not a high/medium priority bug. I can stick to 1.5.3, just wanted to let you know ...

StefanOltmann commented 1 year ago

@AlecStrong Makes sense, yes. I reported it to the SQLiter project.

kpgalligan commented 1 year ago

I am running 1.5.4 with Kotlin 1.7.20 and not running into issues, at least not in the project I'm testing it in. generally speaking, you don't need 1.7.20-specific library dependencies. The binary compatibility tends to go back much longer these days. In earlier versions of Kotlin, each Kotlin update required re-releasing everything, but it's been quite a while since that was an issue.

I'm also not sure that these two issues above have the same cause. They might, but I'd need to see more detail in the error.

If there are any public examples of a repro that will help considerably. ":shared:compileAppleMainKotlinMetadata" also may point to more of a config issue, "Metadata" being the key indicator here.

Looking at the initial issue, if it's a build issue and the error is Unresolved reference: AppDatabase, I'm not sure that has anything to do with Sqliter (maybe, but seems like a different stage of build than Sqliter would be involved in).

kpgalligan commented 1 year ago

So, summary, a repro would help considerably :)

StefanOltmann commented 1 year ago

I'm on an MacBook M1 which seems to contribute to my issue.

@wman1980 Which system you are running on? Intel or M1?

wman1980 commented 1 year ago

Good morning @StefanOltmann , I am working on a M1 as well.

wman1980 commented 1 year ago

Hm ... it looks like that its working with 1.5.4 on a newly created project. @StefanOltmann can you confirm, see attached example project.

SqlDelight.zip

wman1980 commented 1 year ago

hm ... and as a fun fact: I tried my other project as well and upgraded to 1.5.4 again and it seems to work right now!

StefanOltmann commented 1 year ago

@wman1980 Pure guessing here: Your example project uses the older Kotlin 1.7.10, not 1.7.20. Is it possible that this downloads something into the cache that is missing if one goes straight from 1.6.20 to 1.7.20 like I did?

Can't try your sample unfortunately, because I don't have (and don't want) CocoaPods installed.

wman1980 commented 1 year ago

Sorry, forgot to revert 1.7.10 back to 1.7.20.

I have attached another example without cocoapods and kotlin 1.7.20 and it is still working for me.

SqlDelightNoCocoapods.zip