How to read and write file in Swift

In Swift 3 the syntax is a just a few different than the 1 or 2 version:

let file = "file.txt" //this is the file. we will write to and read from it

let text = "some text" //just a text

if let dir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first {

    let path = dir.appendingPathComponent(file)

    // writing
    do {
        try text.write(to: path, atomically: false, encoding: String.Encoding.utf8)
    }
    catch {/* error handling here */}

    //reading
    do {
        let text2 = try String(contentsOf: path, encoding: String.Encoding.utf8)
    }
    catch {/* error handling here */}
}

Source: https://stackoverflow.com/questions/24097826/read-and-write-data-from-text-file

How to delete cache and free space on Xcode

If something goes wrong or the simple Clean and rebuild does not work, you must delete the contents of these folders right now (carefully).

~/Library/Developer/Xcode/DerivedData
~/Library/Developer/Xcode/Archives
~/Library/Developer/Xcode/iOS DeviceSupport
~/Library/Developer/CoreSimulator
~/Library/Caches/com.apple.dt.Xcode
~/Library/Application Support/MobileSync/Backup

Thanks to the source.