Hi there y'all this is my first post on these forums, but not my first time visiting. I've been learning Swift over the past 6+ months and spending a lot of time on the swift.org reference docs, Apple's Swift lang/Foundation docs, Stack Overflow, and here (and the Vapor Discord of all places). So thanks to everyone who answers questions here – I've already benefitted a lot from your contributions!
For my first foray into Swift, I'm actually diving into the nascent server-side Swift space – it has allowed me to focus on learning the language without also learning too many frameworks (e.g. SwiftUI) at the same time. I'm far enough along in the journey to start running builds of my project on a server, and my first step there was to reach for a Linux server. After some poking around with install Swift on Linux (which wasn't so straightforward) I settled on using the official Docker images for my build environment (as this will also work nicely for CI/CD), and then attempted a build.
The only dependencies in my project are Foundation, SQLite3, and Vapor (for the HTTP Server). Swift build appears to fetch all the dependencies for Vapor, then immediately fail on SQLite3 with the error:
No. SQLite3 is missing because it is not part of the standard Swift SDK. On Apple's platforms SQLite3 is present as part of the SDK, but on Linux it is not: you need to bridge it in using the Swift Package Manager. Using the package you linked is likely fine.
If you don't have a good reason to avoid it, you should feel free to use it. The closer you stay to currency data types the better success you'll have. Foundation on Linux is in a state of flux right now, so this is a rapidly evolving space.
Is there a reference for how to do this? I presume this involves ensuring that the libsqlite3-dev package is installed, and then ___? Sorry if I'm missing some obvious reference docs on how to do this.
If you're already using Vapor I'd recommend sqlite-nio, which vendors amalgamated SQLite sources, so you won't need to install SQLite separately, and also provides low-level Swifty wrapper types and functions for it.
Hi folks,
I'm running into the same problem here with a new Vapor install.
I have all the fluent and swift-nio packages that come with the default Vapor installation out of the box. They all appear to be downloaded after starting a build. However I'm receiving the No such module SQLite3`` error.
This is on a Ubuntu server. I'm wondering is there some extra step needed beyond these Swift dependencies?
It compiles fine on my local Mac machine as a Vapor server, or command line app.
Many thanks,
Simon.
Quick note - I did find a simple fix here, might help someone else.
I was able to swap out "import SQLite3" for "import CSQLite" and "import SQLiteNIO".
And then the usual SQLite 3 commands work, with a "sqlite_nio_" prefix on them. For example:
sqlite_nio_sqlite3_open_v2