Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I display my App documents in the Files app for iPhone

Tags:

xcode

swift

I'm trying to show my data in my app in the Files app on my iPhone I searched a lot and did everything right, I don't know where the error is

func fileManger(nameFolder: String) {

    let manager = FileManager.default
    let DecomentFolder = manager.urls(for: .documentDirectory, in: .userDomainMask).last
    let Folder = DecomentFolder?.appendingPathComponent("\(nameFolder)")

    do {
        try manager.createDirectory(at: Folder!, withIntermediateDirectories: true, attributes: [:])
    } catch let error {
        print(error.localizedDescription)
    }
}

Also here I am sending the value to be a folder

@objc func alertNewFolder () {
    let alert = UIAlertController(title: "Create an album", message: "", preferredStyle: .alert)
    alert.addTextField(configurationHandler: nil)
    alert.textFields![0].placeholder = "name album"
    alert.textFields![0].textAlignment = .right
    alert.addAction(UIAlertAction(title: "cancel", style: .cancel, handler: nil))
    alert.addAction(UIAlertAction(title: "save", style: .default, handler: { ـ in
        if let textFileds = alert.textFields {
            let links = textFileds[0].text
            self.arrS1.append(addCatogrey(nameCatog: links!, imageSection: UIImage(named: "folder")))
// Here Send FileManager
            helperCoding().fileManger(nameFolder: links!)
            self.collection.reloadData()
        }
    }))
    self.present(alert, animated: true, completion: nil)
}

In the Simulators it saved in the Documents folder here correctly

/Users/badrshammry/Library/Developer/CoreSimulator/Devices/7986A27F-7026-45E1-9073-78CCD6A9B90A/data/Containers/Data/Application/3173C4DC-BCDE-41B9-89E1-6E8D9B52EF25/Documents
like image 858
Badrshammry Avatar asked Nov 24 '25 15:11

Badrshammry


1 Answers

If you would like to expose your App document files inside Apple's Files App you need to include the "Supports Document Browser" key in your info plist file and set it to YES:

enter image description here

like image 99
Leo Dabus Avatar answered Nov 27 '25 08:11

Leo Dabus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!