虽然这在设备上的Simulator中可以正常工作,但是当我的自定义键盘扩展尝试在包含应用程序编写的共享容器中打开UIDocument时,却无法执行。将以下内容记录到控制台:
tickerB = [{
baseAsset: 'AUD',
lastPriceUSD: 0.76,
volume: 2000
}, {
baseAsset: 'USD',
lastPriceUSD: 1.25,
volume: 1500
}]
报告给UIDocument.handleError(:userInteractionPermitted :)的错误不是很有帮助:
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.
我在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}
子类的viewDidLoad()
中打开文档:
UIInputViewController
此崩溃发生的可能性为100%。在信息列表中,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)
}
}
是RequestsOpenAccess
。再次,这在模拟器中有效。我也在我拥有的iOS 9.5.3 iPad上进行过尝试,并且出现了类似的崩溃。
为什么会在设备上崩溃?