Lighter-swift / Lighter

Swift APIs for SQLite: Type-safe down to the schema. Very, very, fast. Dependency free.
https://lighter-swift.github.io/documentation/lighter/
MIT License
409 stars 10 forks source link

Xcode 15 issue when the creation script is named the same like the DB #27

Open smithi01 opened 7 months ago

smithi01 commented 7 months ago

Your package looks outstanding. Thank you. I would like to use it to replace GRDB in my current app development. I followed the getting started steps but instead of using an existing database, I added stations.sql to my project.

I get this Xcode error. Multiple commands produce '/Users/iansmith/Library/Developer/Xcode/DerivedData/TryLighterStations-euddgsmncyclyietjarityspmrwp/Build/Products/Debug-iphonesimulator/TryLighterStations.app/station.sql'

The error also provides this information.

This is my station.sql: CREATE TABLE station ( country_code TEXT, home_page TEXT, icon_url TEXT, latitude REAL, longitude REAL, name TEXT NOT NULL, ordered_by_name TEXT NOT NULL, location TEXT NOT NULL, id TEXT NOT NULL PRIMARY KEY, url TEXT NOT NULL, genre_list TEXT );

CREATE INDEX country_index ON station (country_code); CREATE INDEX name_index ON station (name); CREATE INDEX ordered_by_name_index ON station (ordered_by_name);

CREATE TABLE station_genre ( genre TEXT NOT NULL, station_id TEXT NOT NULL REFERENCES station (id) ON DELETE CASCADE )

I am using Xcode Version 15.0.1 (15A507) and running on an ios17 simulator.

Perhaps I am not adding the .sql file to my project correctly. I am at a loss about where I went wrong. I would be most grateful for any guidance you could offer.

smithi01 commented 7 months ago

TryLighterStations.zip

helje5 commented 7 months ago

I'll have a look

smithi01 commented 7 months ago

Thanks so much. I just had a thought, which fixed it! I renamed station.sql to stationCreation.sql and all is good! Perhaps the problem is that the database and the table had the same name. I have since renamed it again to stationDB-001.sql and all good,

kebbbnnn commented 6 months ago

Had the same issue building my iOS project when I upgraded to Xcode 15. What I did is, from Build Phases, I moved the ".sql" file from Copy Bundle Resources to Compile Sources, then everything went back to normal again.

helje5 commented 6 months ago

Ah, that makes sense. I wonder whether DB embedding broke w/ that thought (they need to be both compiled and copied) (vs .sql files, which you don't usually want to copy as resources).

kebbbnnn commented 6 months ago

I just tested, Xcode 15 broke the db embedding too. I experimented with spm and created a swift package for my db manager then moved all db related sources and files (sql and sqlite3) there and now it works.

helje5 commented 6 months ago

Yes, that would be the workaround I've would have tried as well. I.e. moving things to a Local Package probably makes it work. It was already required when importing SPM packages that used package plugins (e.g. Northwind.swift).

helje5 commented 3 months ago

I'm slightly confused where we are with that and what issues we have. Does the new title contain all issues we have here? Do we need a separate issue for embedding DBs?