Swift only. Objective-C files are not required.
Here is another solution that uses SQLite.swift instead of FMDB .
1 .: Get the correct path to your database file
Do not save the database file in the Resources folder, but add it to the Copy Set Resources list in the Build Phases setting of the current target. If your file is called myDb.db you can get the correct path, for example:
let dbUrl = Bundle.main.url(forResource: "myDb", withExtension: "db")! let dbPath = dbUrl.path
2 .: Access to your database (without copying)
Now you can access your database without having to (manually?) Copy it. Just use the SQLite.swift library:
db = try! Connection(dbPath)
Notes: The only thing I have not verified yet is writing to the database. At least read-only access works like a charm, though.
source share