How can I find my app created log on my iPhone?

I am using the code below to create my own debug log for my app. On the simulator, I have no problem viewing that log. I simply print out the documents directory in the debugger, then open it in my finder.

However I do not know how to access the created log on my iPhone itself. Even if I go to Window -> Devices and Simulator's, when I look at my app's container it's empty. Although I would like to be able to access the file from any actual device in the future.

Am I using the wrong directory? I even used allDomainsMask in place of userDomainMask below, but to no avail.

debugFileURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("myApp.log")
if let handle = try? FileHandle(forWritingTo: dbClass.debugFileURL!) {
	handle.seekToEndOfFile() // moving pointer to the end
	handle.write(text.data(using: .utf8)!) // adding content
	handle.closeFile() // closing the file
} else {
	try! text.write(to: dbClass.debugFileURL!, atomically: false, encoding: .utf8)
}

Accepted Reply

For anyone running into this problem, it's a permission issue. Answer is here.

Replies

For anyone running into this problem, it's a permission issue. Answer is here.