DevZer0 DevZer0 - 2 years ago 96
Swift Question

Get the absolute path of .app bundle in OS X using swift

I am trying to find the path of where a simple OS X app is running from. I tried

let fileManager = NSFileManager.defaultManager()
let path = fileManager.currentDirectoryPath

always has value
. How do I get the absolute path, such as if the
is executed from
I expect the value

is it possible?

Answer Source

Use NSBundle:

let path = NSBundle.mainBundle().bundleURL.URLByDeletingLastPathComponent!.path!
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download