1

I have managed to install SQLite.swift (0.18.1) using the "Carthage approach".

I can "import SQLite" and do some other stuff, but when I try to open a database, using the following code:

let db = try Connection("~/db.sqlite3")

and run my program (which is far from complete, but I'm taking it step by step), I get the following nasty error:

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /Volumes/MBP-Data/rob/Library/Developer/Xcode/DerivedData/PFA-Analysis_(Swift)-advmptllvbeczrdcmjxnkcpsqogx/Build/Products/Debug/SQLite.framework/Versions/A/SQLite
  Reason: image not found
(lldb)

To me it looks like it's related to the command trying to open the database as when I leave that command out, my code runs fine. Trying different paths for the database and different extensions of the database ik sta in de file itself didn't help either. Actually, it made no difference.

As I'm pretty new, I don't know where to start looking, so any help with getting me up to speed is really appreciated!

Eric Aya
  • 69,473
  • 35
  • 181
  • 253

1 Answers1

2

What I know is that the database file extension doesn't matter (so you could have .sqlite or .db or .database )

I've done it that way:

var database: Connection {
    return try! Connection(Constants.Database.databaseFilePath)
}

Where Constants.Database.databaseFilePath is

static let databaseFilePath = "\(NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask,true)[0])/\(databaseFileName)"

and databaseFileName is something like

static let databaseFileName = "parky.db"

The code from databaseFilePath returns the actual path of the database file inside the iOS container. That's how I've managed it to work.

Look if Carthage added the SQLite library to the embedded frameworks in Xcode? Carthage Documentation

Coupz
  • 531
  • 7
  • 11