Skip to content

Instantly share code, notes, and snippets.

@geekforbrains
Last active May 30, 2018 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekforbrains/2a0ac7e3233c4116e1df to your computer and use it in GitHub Desktop.
Save geekforbrains/2a0ac7e3233c4116e1df to your computer and use it in GitHub Desktop.
Print the full path to your iOS simulators documents directory
#if arch(i386) || arch(x86_64)
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as! NSString
NSLog("Document Path: %@", documentsPath)
#endif
@geekforbrains
Copy link
Author

I use this in the AppDelegate to print out the full path. Makes it easier to quickly access that directory. The #if block ensures its only run in dev mode (simulator).

@yasper
Copy link

yasper commented May 30, 2018

A Swift 4 updated-version:

extension UIDevice {
    class func printFolderPath() {
        let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
        NSLog("✅ \(documentsPath)")
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment