iOS introduced a way for users to transfer files from an app to a computer via iTunes.
It is simply adding
UIFileSharingEnabled to info.plist. There is a very small introduction here.
When you enable file sharing, ALL files in
<Application_Home>/Documents will be shared.
Users can copy files to and from the app, as well as delete.
So be cautious of that.
You might also want to monitor the directory. There is a way to do that using
Write to directory (in Swift)
The API is via
// The Documents for every app let documentDirectory = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: false) // Make sure you create any inner directories let imageDirectory = documentDirectory.appendingPathComponent("/export/images/") try! FileManager.default.createDirectory(at: imageDirectory, withIntermediateDirectories: true, attributes: nil) // Write some data try! data.write(to: imageDirectory.appendingPathComponent("lion.jpg"))
If you want to access the app container on the simulator, you need to:
- Run on simulator
- Pause, and
- Open the directory in Finder and do whatever you want :)