I am trying to create a folder for my app in the Files app for access when i want to save a file from my app
In iOS 12 and earlier i could achieve this by enabling
Application supports iTunes file sharing
and Supports opening documents in place
as shown below
Since updating to iOS 13, the same folder that used to show up in iOS 12 no-longer shows.
What has changed and how can i get this resolved in iOS 13?
I use the extension below to save files:
extension WebViewController: URLSessionDownloadDelegate {
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {
// create destination URL with the original pdf name
guard let url = downloadTask.originalRequest?.url else { return }
let documentsPath = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)[0]
let destinationURL = documentsPath.appendingPathComponent(url.lastPathComponent)
// delete original copy
try? FileManager.default.removeItem(at: destinationURL)
// copy from temp to Document
do {
try FileManager.default.copyItem(at: location, to: destinationURL)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2){
let activityViewController = UIActivityViewController(activityItems: [self.fileName, destinationURL], applicationActivities: nil)
if(UIDevice.current.userInterfaceIdiom == .pad){
if let popOver = activityViewController.popoverPresentationController {
popOver.sourceView = self.view
popOver.sourceRect = self.view.bounds
popOver.barButtonItem = self.navigationItem.rightBarButtonItem
self.present(activityViewController, animated: true, completion: nil)
}
}
else{
self.present(activityViewController, animated: true, completion: nil)
}
}
} catch let error {
print("Copy Error: \(error.localizedDescription)")
}
}
}