SwiftData pitfalls

I’ve been exploring SwiftData lately, and I’ve been unpleasantly surprised by how many sharp edges it has. I’m going to try to describe some of them here, so that hopefully others can avoid them (or perhaps be dissuaded from using SwiftData to begin with). I’m using Xcode 15.0.1 (Swift 5.9) on macOS 14.1 (Sonoma). Background… Read more

SQLite table constraints must be specified after all columns

Marking this one for future reference. TL;DR:  You have to specify all the columns in your table, in a CREATE TABLE statement, before you specify table constraints like primary or foreign keys. SQLite gives the most useless error messages most of the time.  Case in point: CREATE TABLE “Foo” ( “ColumnA” TEXT NOT NULL UNIQUE, “ColumnB”… Read more