I have yet to see documentation of a Swift standard library, where I would expect to find something like a File class or struct with an interface for opening, reading, and writing files. All the usual stuff you expect for File IO. Is there one, or are to depend on NSFileManager and its ilk?
Browse and open files and folders Tap Browse at the bottom of the screen, then tap an item on the Browse screen. If you don't see the Browse screen, tap Browse again. To view recently opened files, tap Recents at the bottom of the screen. To open a file, location, or folder, tap it.
Do a print(path. absoluteString) and then $ open path in Terminal, to open the file or folder at path. Keep in mind that the directory (on your Mac) where a Simulator's files are stored can change between running your app.
Here's a way to do it if the file is in your iOS project (hoping this is your situation):
var filePath = Bundle.main.path(forResource: "theFile", ofType: "txt")
var data = Data(contentsOf: URL(fileURLWithPath: filePath))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With