Zap*_*hod 8 ios xcode10 ios13 xcode11
UIDocumentBrowserViewController在iOS 13上进行测试时,我遇到了一个非常奇怪的问题。importHandler(newDocumentURL, .move)似乎无缘无故地崩溃了:
[DocumentManager] Cannot create urlWrapper for url file:///.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt.
error Error Domain=NSPOSIXErrorDomain Code=22 "couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt':
Invalid argument" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.app-sandbox.read-write for '/.../tmp/23720D22-BC1D-4E7B-A7AE-A1C8B0293F9E.txt': Invalid argument}.
Run Code Online (Sandbox Code Playgroud)
这是一个复制的两步过程:
在 documentBrowser(_: , didRequestDocumentCreationWithHandler:)
let newDocumentURL: URL? =
URL(fileURLWithPath: NSTemporaryDirectory())
.appendingPathComponent(UUID().uuidString)
.appendingPathExtension("txt")
// Set the URL for the new document here. Optionally, you can present a template chooser before calling the importHandler.
// Make sure the importHandler is always called, even if the user cancels the creation request.
if newDocumentURL != nil {
print(newDocumentURL!)
try! "My file content".write(to: newDocumentURL!, atomically: true, encoding: .utf8)
importHandler(newDocumentURL, .move)
} else {
importHandler(nil, .none)
}
Run Code Online (Sandbox Code Playgroud)在iOS 13模拟器上启动它,创建一个新文档,错误被打印出来,其他任何事情都没有发生。
如果您在iOS 12上执行相同的代码,则可以完美运行,该文件将被移动并由应用打开。
该问题发生在iOS 13 beta 7上,无论它是由Xcode 11 beta 7还是Xcode 10.3编译的
任何的想法?
编辑:当您在文档目录而不是临时目录中创建文件时,仍然会出现问题:
FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
Run Code Online (Sandbox Code Playgroud)
编辑2:Xcode 11 GM(11A419c)仍然存在问题
编辑3:问题仅存在于模拟器。在装有iOS 13 GM的设备上,UIDocumentBrowserViewController可以正常工作。
编辑4:问题仍然存在于带有官方Xcode 11版本11A420a(又名GM种子2)的模拟器上。
编辑5:问题仅发生在莫哈韦沙漠上,并且在卡塔琳娜州似乎不存在
我已验证在 Mac OS Mojave 上运行的 Xcode 11.1 GM 存在该错误。
在 Catalina Beta 9 上运行时不会出现此问题。(FWIW 我在 Parallels 虚拟机中运行 Catalina Beta 9,因为我不知道它是否足够稳定,可以升级到生产工作。)
寻找解决方法,如果我找到任何解决方法,我会发布(但请注意,这不是我的专业领域,只是根据预感进行操作,结果证明是正确的。)
您可能需要更新您提交的雷达,以表明这可能是莫哈韦特有的。
| 归档时间: |
|
| 查看次数: |
539 次 |
| 最近记录: |