stringByAppendingPathComponent is unavailable

You can use:

let dbPath = (documentsFolder as NSString).stringByAppendingPathComponent("db.sqlite")

You can create a URL rather rather than a String path.

let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first
let fileURL = documentsURL?.appendingPathComponent("test.sqlite")

If you absolutely need the path, then you can get it like this:

guard let path = fileURL?.path else {
    return
}

print(path) // path will exist at this point

There was some discussion in the thread you mentioned that Apple may be purposely guiding people toward using URLs rather than String paths.

See also:

  • What's the difference between path and URL in iOS?
  • NSFileManager URL vs Path
  • Swift 2.0: Why Guard is Better than If

Tags:

Ios

Swift

Swift2