Swift – Home Directory for Current User
To get home directory for current user in Swift, read
homeDirectoryForCurrentUser property of shared file manager object for the process.
The following code snippet returns the home directory of the current user.
In the following example Swift program, we will get the home directory of the current user, using the code snippet mentioned above.
import Foundation let home = FileManager.default.homeDirectoryForCurrentUser print(home)
In this Swift Tutorial, we learned how to get the path to home directory of current user.