· 1 min read

How to Find the Directory Locations Your XCode App Uses

You can add this snippet to your application, say for instance in your viewDidLoad function, that will print to the XCode console, the location of your app while it's being developed.

    // prints the location of asset my-added-file.txt that you've added to the project
print(Bundle.main.path(forResource: "my-added-file", ofType:"txt") as! String)
    // prints the location of the Documents directory your app has access to
print( FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] )
    // prints the location of the application support directory
print( NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true) )

Comments

Leave a comment