-
-
Notifications
You must be signed in to change notification settings - Fork 796
Simplify the compiler checks for the availability of SQLite snapshots #1826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hello @thinkpractice, @marcprux, @R4N, I think I took care of Linux and future SQLCipher traits in this pull request, but I'd rather check with you. |
|
Did a quick check with Hope this helps! UPDATE same errors with |
|
I don't know what I did. I'm pushing the fix shortly 😅 |
14886b5 to
fbad7fb
Compare
|
This time I ran I'm pretty excited with this opportunity to cleanup this heritage. Look at what this condition used to be (Xcode used to ship with a completely fucked up support for snapshots): |
|
Ok it builds now under Linux. To see whether it also links we need to build the tests though and for that we need my changes... |
|
Still not OK… I'm on it. |
|
WTF. the compiler flag for a trait is set when I build the package itself. But it is not set when I build an Xcode app that depends on GRDB. LOL Apple. No Xcode user will be able to use our nice new traits. I'm working on a fix for Xcode apps (restricted to the default trait). |
|
I think I have it. I'm running the full test suite before pushing again. I asked about my understanding of the Xcode behavior: https://hachyderm.io/@groue/115316283468396358 |
|
Woot! I get it. I will rebase #1819 on top once this PR is merged. @R4N, @marcprux, this is the new import boilerplate: #if GRDBCIPHER // CocoaPods (SQLCipher subspec)
import SQLCipher
#elseif GRDBFRAMEWORK // GRDB.xcodeproj or CocoaPods (standard subspec)
import SQLite3
#elseif GRDBCUSTOMSQLITE // GRDBCustom Framework
// #elseif SomeTrait
// import ...
#else // Default SPM trait must be the default. It impossible to detect from Xcode.
import GRDBSQLite
#endifHere is the translation in human language:
If none of the above condition is met, we assume we enter the SPM territory:
It is crucial that the default trait is handled last, without any specific |
We can not use `#if Trait` because Xcode does not enable those compiler flags. Always count on Apple for delivering the best quality software. So now we import the default SPM SQLite last, after all other cases have been excluded. The GRDB framework (GRDB.xcodeproj and GRDB via CocoaPods) is distinct from the default SPM trait, so we detect it with GRDBFRAMEWORK.
6ed6262 to
8cba324
Compare
|
All right, all test passes. I'll leave this open for a while so that you all have the time to comment, before I complete #1819 (preliminary support for SQLCipher). Fortunately #1825 (Linux) is unrelated. After that #1708 (SQLCipher from Marc) will be easier to deal with as well. We're lacking a central place to discuss together 😅 |
@thinkpractice @marcprux @R4N @sjlombardo do you all have an account on the Swift forums? We could open a thread in the GRDB sub-forum so that we do not have to chase the latest messages on GitHub. Please tell me what you think. |
This pull request fixes #1826, which broke `make test_GRDBDemo` with Xcode 26.0.1. To reproduce the failure: - Remove from ~/Library/Developer/Xcode/DerivedData all previous builds of GRDB and related stuff - Run `make distclean test_GRDBDemo` We expect a success, but it fails with error "Unable to find module dependency: 'GRDBSQLite'".
This pull request makes it easier to deal with various SQLite versions (SQLite on Darwin, SQLite on Linux, various SQLCipher flavours), by using the sole
SQLITE_ENABLE_SNAPSHOTcompiler flag when checking for the availability of SQLite snapshots.SQLite snapshots enable GRDB features such as
DatabaseSnapshotPool, and they are an important tool that helpsValueObservationbehave nicely when observing changes in aDatabasePool. When an app starts observing the database and gets the initial value very quickly, even in the case of eventual concurrent writes, without fearing that GRDB misses a change or performs unneeded database requests, well this is all thanks to SQLite snapshots.Package.swiftnow definesSQLITE_ENABLE_SNAPSHOTby default, enabling support for SQLite snapshots, unless a package trait definesSQLITE_DISABLE_SNAPSHOT.The reason why snapshot support is enabled by default is that Xcode does not properly supports package traits. An Xcode project that depends on GRDB must profit from snapshots, and this can only be achieved when Package.swift unconditionally defines
SQLITE_ENABLE_SNAPSHOT. 🤷♂️Other changes:
@Marus, you expressed concerns about bumping the minimum Swift version a few days ago. Practically speaking, this can only impact people who can not use Xcode 16.3+, so I'm going to ship this breaking change. Please share specific concerns if you have any.