Search code examples
swiftswift-package-managergrdb

How to enable FTS5 in GRDB.swift using SPM?


I'm using GRDB.swift package for communication with Database in App project. Package is added using Swift Package Manager. I would like to use FTS5, but as far as I see the FTS5 struct has condition #if SQLITE_ENABLE_FTS5.

Is there a way to enable it using SPM (not Cocoapods)?


Solution

  • Update February 22, 2022: FTS5 is automatically enabled with Swift Package Manager starting GRDB version 6.7.0.

    Users of previous versions of GRDB can use the previous answer below:


    The supported methods for enabling FTS5 are documented at Enabling FTS5 Support: CocoaPods, or a custom SQLite build.

    FTS5 support can not be achieved in the main repo with SPM, because SPM can't enable features depending on the target operating system (FTS5 is only iOS 11.4+, but GRDB still has a requirement on iOS 11+).

    Some people fork GRDB in order to enable FTS5 with SPM. The trick is to append SQLITE_ENABLE_FTS5 to the Swift settings.