groue / GRDBCombine

GRDB ❤️ Combine
MIT License
223 stars 16 forks source link

Installation instructions for use with custom build of SQLite #15

Closed cfilipov closed 4 years ago

cfilipov commented 4 years ago

How do you install GRDBCombine with a custom build of SQLite? I would like to make use of several SQLite build options such as JSON1 with this package.

groue commented 4 years ago

Hi @cfilipov, glad to see you here :-)

First, the stock SQLite libraries shipped with Apple systems come with pre-built extensions, and I think JSON1 has been available for a while. It's worth wondering if you really need a custom SQLite build. But this is not your question.

There is no such ready-made packaging of GRDBCombine at this point.

I'm not aware of any SPM-compatible way to use custom SQLite builds, although there is an exploration of the topic, for SQLCipher, at https://github.com/groue/GRDB.swift/pull/556 (it's hard).

There is a documented way to build GRDB+Custom SQLite, and an alternative way I discovered recently, by @benasher44, which uses CocoaPods (see the Podfile at https://github.com/CocoaPods/CocoaPods/issues/9104).

Maybe I'd start with the previous paragraph, grab the GRDBCombine sources, and glue everything :-)

groue commented 4 years ago

Should this issue turn into a pull request, i'd definitely recommend adding a podspec for GRDBCombine, including a subspec GRDBCombine/SQLCipher. RxGRDB offers a good starting point: https://github.com/RxSwiftCommunity/RxGRDB/blob/master/RxGRDB.podspec

On this base, the CocoaPods technique for using a custom SQLite build, linked in my previous comment, should work like a charm.

Not too much work, and high benefit.

However, the real meat since the release of Xcode 11 is the SPM-compatible way to use a custom SQLite build. There's extra bonus points here :-) cc @hartbit

cfilipov commented 4 years ago

I did not realize iOS started including the JSON1 extension. I was basing my information off of the defaults described in swiftlyfalling/SQLiteLib. I do have other extensions which I'm interested in, how do you know which flags iOS used (google search only had outdated info)?

groue commented 4 years ago

I don't know, I could never find proper release notes. You're in for launching simulators and check...

cfilipov commented 4 years ago

By the way, if iOS now includes JSON1 it would be good to update your table creation ColumnType to include .json? The JSON1 docs don't explicitly mention a new data type for JSON but it is used in the code listing in section 4.13. I can file a ticket in the main GRDB project.

EDIT:

I missed this earlier in the JSON1 docs:

Backwards compatibility constraints mean that SQLite is only able to store values that are NULL, integers, floating-point numbers, text, and BLOBs. It is not possible to add a sixth "JSON" type.

So I'm guessing JSON is equivalent to TEXT. Makes sense with how sqlite treats things with their "type affinity".

groue commented 4 years ago

So I'm guessing JSON is equivalent to TEXT.

Yes it is. Now I haven't used JSON1 myself, so I had no opportunity to think if GRDB could help in any way.

groue commented 4 years ago

I'm closing this issue. Feel free to reopen if any new element comes up.