I recently started an iOS project and need to work with a standalone database that'll be downloaded from the internet when there are updates. This is my first iOS project, so am trying to get functionality working before designing the download mechanism.
I've selected the SQLite wrapper SWLite.swift
(https://github.com/stephencelis/SQLite.swift) and have my queries and table views ready to roll. But I can't connect to the DB. I've tried just about every other question/answer on here with absolutely no success.
For example, I dropped the SQLite database into the Assets.xcassets
and tried let path = Bundle.main.path(forResource: "myDb", ofType: "db")!
, and the app crashes (as I got nil
back -- presumably because the path couldn't be located). LikewiseI tried what others suggested, including creating a folder on my Mac, dropping the file into it, appending .bundle
to the folder name, and dropping that into the Assets... again, nil
.
Could anybody advise? I've looked at the Apple Docs and couldn't really find what I was looking for -- again, this is my first time, so maybe I'm doing it wrong.