我的自定义键盘无法共享数据,因为 filecoordinationd 正在崩溃(在设备上)

My custom keyboard can't share data because filecoordinationd is crashing (on device)

虽然这在模拟器中运行良好,但在设备上,当我的自定义键盘扩展试图在包含应用程序编写的共享容器中打开 UIDocument 时,它无法这样做。以下内容记录到控制台:

2019-05-10 15:39:09.640305-0700 TagManagerKeyboard[15249:1890026] [claims] 528516A6-B168-43EA-8AAF-B7B1754EE42E grantAccessClaim message failed: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.FileCoordination was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.FileCoordination was invalidated.}
2019-05-10 15:39:09.640891-0700 TagManagerKeyboard[15249:1890026] A process invoked one of the -[NSFileCoordinator coordinate...] methods but filecoordinationd crashed. Returning an error.

报告给 UIDocument.handleError(:userInteractionPermitted:) 的错误不是很有帮助:

Error Domain=NSCocoaErrorDomain Code=256 "The file “MyFile” couldn’t be opened." UserInfo={NSURL=file:///private/var/mobile/Containers/Shared/AppGroup/3A486D56-F897-4B13-A09F-0B4183686E2C/MyFile}

我在 UIInputViewController 子类的 viewDidLoad() 中打开文档:

if let container = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.com.mycompany.MyApp")
{
    let containerPath = Path(container.path)
    let file = containerPath + "MyFile"
    self.doc = MyDocument(fileURL: file.url)
    debugLog("Extension doc at \(file)")
    self.doc.open
    { (inSuccess) in
        debugLog("Opened doc: \(inSuccess)")
        NotificationCenter.default.post(name: .dataUpdated, object: nil)
    }
}

此崩溃的发生率为 100%。 RequestsOpenAccess 是 Info.plist 中的 YES。同样,这在模拟器中有效。我也在 iOS 9.5.3 iPad 上试过,它也有类似的崩溃。

知道它为什么会在设备上崩溃吗?

出现这种情况是因为我的键盘没有设置“允许完全访问”。