Swift’s String.write(toFile:…) can’t handle tildes
let path = “~/Desktop/sigh.txt” try “WTF?”.write(toFile: path, atomically: true, encoding: .utf8) Result? Explode: Error Domain=NSCocoaErrorDomain Code=4 “The folder “sigh.txt” doesn’t exist.” UserInfo={NSFilePath=~/Desktop/sigh.txt, NSUserStringVariant=Folder, NSUnderlyingError=0x1018110b0 {Error Domain=NSPOSIXErrorDomain Code=2 “No such file or directory”}} And since there’s no documentation on that write() method, and this is obviously a perfectly reasonable request that can’t sanely yield that bizarre … Read more