In addition to including the keys you mentioned, I assume you also include the document types your app supports in the Info.plist (with CFBundleDocumentTypes and UTExportedTypeDeclarations).
Next, you must use UIDocument for your files. Here is an example:
final class CustomDoc: UIDocument {
override func contents(forType typeName: String) throws -> Any {
return "This is a test".data(using: .utf8)!
}
override func load(fromContents contents: Any, ofType typeName: String?) throws {
}
}
func saveTestDocument() {
let localDocs = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
try? FileManager.default.createDirectory(at: localDocs, withIntermediateDirectories: true, attributes: nil)
let test = localDocs.appendingPathComponent("Test").appendingPathExtension("testfile")
let doc = CustomDoc(fileURL: test)
doc.save(to: doc.fileURL, for: .forCreating) { completion in
print("completion: \(completion)")
}
}
I was able to get the recent files popover to work by including the proper Info.plist keys and using the code above.