0

Followed the exact steps from here

My code

func save() {
    do {
        if let containerUrl = FileManager.default.url(forUbiquityContainerIdentifier: nil)?.appendingPathComponent("Documents") {
            if !FileManager.default.fileExists(atPath: containerUrl.path, isDirectory: nil) {
                do {
                    try FileManager.default.createDirectory(at: containerUrl, withIntermediateDirectories: true, attributes: nil)
                } catch {
                    print(error.localizedDescription)
                }
            }                   
            let fileURL = containerUrl.appendingPathComponent("test2.txt")
            
            if FileManager.default.fileExists(atPath: fileURL.path, isDirectory: nil) {
                try FileManager.default.removeItem(at: fileURL)
            }
            try data.write(to: fileURL)

            print("Drawing saved to \(fileURL)")
        }
    } catch {
        print("Error saving drawing: \(error)")
    }
}

my info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>UISupportsDocumentBrowser</key>
    <true/>
    <key>NSUbiquitousContainers</key>
    <dict>
        <key>iCloud.com.mycompany.TestSketchSave</key>
        <dict>
            <key>NSUbiquitousContainerIsDocumentScopePublic</key>
            <true/>
            <key>NSUbiquitousContainerName</key>
            <string>TestSketchSave</string>
            <key>NSUbiquitousContainerSupportedFolderLevels</key>
            <string>Any</string>
        </dict>
    </dict>
</dict>
</plist>

iCloud container id is iCloud.com.mycompany.TestSketchSave, app id is com.mycompany.TestSketchSave

Files successfully shows up in iCloud Drive settings

According to the post's answer I have also upgraded the version number of the app.

Still does not show in the File app

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
erotsppa
  • 14,248
  • 33
  • 123
  • 181
  • When you run the Files app and go to the iCloud section, do you see the `TestSketchSave` folder? If so, does it contain a `Documents` folder? – HangarRash May 01 '23 at 03:46
  • @HangarRash no, the icloud section does not even have the TestSketchSave folder – erotsppa May 01 '23 at 19:46

0 Answers0