NSHomeDirectory() is retuning my sandbox root, not my home directory. [@\"~\" stringByExpandingTildeInPath] is doing the same thing.
This <
Using Swift, you can access the users home directory path from a sandboxed app like this:
var userHomeDirectoryPath : String {
let pw = getpwuid(getuid())
let home = pw?.pointee.pw_dir
let homePath = FileManager.default.string(withFileSystemRepresentation: home!, length: Int(strlen(home)))
return homePath
}
I created this solution based on a snippet in this blog post: http://zpasternack.org/accessing-the-real-home-folder-from-a-sandboxed-app/