Lighter-swift / Lighter

Swift APIs for SQLite: Type-safe down to the schema. Very, very, fast. Dependency free.

Home Page:https://lighter-swift.github.io/documentation/lighter/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

smithi01 opened this issue · comments

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.

  • Target 'TryLighterStations' (project 'TryLighterStations') has copy command from '/Users/iansmith/Documents/Developer/Tutorials, Examples and Experiments/Experiments/TryLighterStations/TryLighterStations/TryLighterStations/station.sql' to '/Users/iansmith/Library/Developer/Xcode/DerivedData/TryLighterStations-euddgsmncyclyietjarityspmrwp/Build/Products/Debug-iphonesimulator/TryLighterStations.app/station.sql'
  • Target 'TryLighterStations' (project 'TryLighterStations') has copy command from '/Users/iansmith/Library/Developer/Xcode/DerivedData/TryLighterStations-euddgsmncyclyietjarityspmrwp/SourcePackages/plugins/TryLighterStations.output/TryLighterStations/Enlighter/station.sql' to '/Users/iansmith/Library/Developer/Xcode/DerivedData/TryLighterStations-euddgsmncyclyietjarityspmrwp/Build/Products/Debug-iphonesimulator/TryLighterStations.app/station.sql'

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.

I'll have a look

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,

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.

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).

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.

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).

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?