I’m making an attempt to jot down a easy textual content file into the Paperwork folder on my iPhone from inside my Swift app. The code runs efficiently, i.e., I get the “All Good!” message, however I can’t find the file anyplace within the Information app.
I’m utilizing Xcode 15.2 on a MacBook operating macOS 14.2.1. My machine goal is an iPhone 14 Professional operating iOS 17.2.1.
This is my code:
let docDir = URL.documentsDirectory
let fileURL = docDir.appendingPathComponent("testfile.txt", conformingTo: .textual content)
FileManager.default.createFile(atPath: fileURL.path, contents: nil, attributes: nil)
let sampleString = "take a look at take a look at take a look at"
do {
let fileHandle = strive FileHandle(forWritingTo: fileURL)
fileHandle.write(Information(sampleString.utf8))
strive fileHandle.shut()
print("All Good!")
} catch {
print("File error: (error)")
}