I am making a func that edits a text file in the Users/johnDoe Dir.
let filename = \"random.txt\" let filePath = \"/Users/johnDoe\" let replacementText = \"
You can use FileManager property homeDirectoryForCurrentUser
let homeDirURL = FileManager.default.homeDirectoryForCurrentUser
If you need it to work with earlier OS versions than 10.12 you can use
let homeDirURL = URL(fileURLWithPath: NSHomeDirectory())
print(homeDirURL.path)