UIDocumentBrowserViewController错误“无法为URL创建urlWrapper".在iOS13模拟器上 [英] UIDocumentBrowserViewController error "Cannot create urlWrapper for url" on iOS13 simulator

查看:147
本文介绍了UIDocumentBrowserViewController错误“无法为URL创建urlWrapper".在iOS13模拟器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 13上进行测试时,UIDocumentBrowserViewController有一个非常奇怪的问题.importHandler(newDocumentURL, .move)似乎无缘无故地崩溃:

I have a very strange problem with UIDocumentBrowserViewController when testing on iOS 13. The importHandler(newDocumentURL, .move) seems to crash without any reason :

[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}.

这是一个两步重现的过程:

Here is a two step process to reproduce :

  • 创建一个新的Xcode项目基于文档的应用程序"
  • 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)
}

在iOS 13模拟器上启动它,创建一个新文档,并打印出错误,并且什么都没有发生.

Launch it on an iOS 13 simulator, create a new document, and the error is printed out and nothing else happens.

如果您在iOS 12上执行相同的代码,则可以完美运行,该文件将被移动并由应用打开.

If you execute the same code on iOS 12, it perfectly works, the file is moved and is opened by the app.

问题是在iOS 13 beta 7上发生的,无论它是由Xcode 11 beta 7还是Xcode 10.3编译的

The problem occurs on iOS 13 beta 7, wether it's compiled by Xcode 11 beta 7 or Xcode 10.3

有什么主意吗?

编辑:当您在文档目录而不是临时目录中创建文件时,仍然会出现问题:

EDIT: The problem still occurs when you create the file in the document directory instead of the temporary directory :

FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]

编辑2 :Xcode 11 GM(11A419c)仍然存在问题

EDIT 2: The problem still exists with Xcode 11 GM (11A419c)

编辑3 :该问题仅在模拟器上仍然存在.在装有iOS 13 GM的设备上,UIDocumentBrowserViewController可以正常工作.

EDIT 3: The problem persists only the simulator. On device with iOS 13 GM, UIDocumentBrowserViewController works as expected.

编辑4 :在官方Xcode 11版本11A420a(又名GM种子2)上的模拟器上仍然存在问题

EDIT 4: Problem still present on simulators with official Xcode 11 release 11A420a (aka GM Seed 2.)

编辑5 :问题仅在Mojave上出现,并且在Catalina上似乎不存在

EDIT 5: Problem only occurs on Mojave and seems to be absent on Catalina

推荐答案

我已经验证了在Mac OS Mojave上运行的Xcode 11.1 GM存在该错误.

I've verified that the bug exists with Xcode 11.1 GM running on Mac OS Mojave.

在Catalina Beta 9上运行时,不会发生此问题.(FWIW我在Parallels虚拟机中运行了Catalina Beta 9,因为我不知道它是否足够稳定以升级到用于生产工作.)

The issue does not occur when running on Catalina Beta 9. (FWIW I ran Catalina Beta 9 in a Parallels virtual machine because I don't know if it is stable enough to upgrade to for production work.)

寻找变通办法,如果我发现有任何变通办法,则会发布(但请注意,这不是我的专业领域,只是凭直觉就证明是正确的.)

Looking for workarounds, will post if I find any (but note this is not my area of expertise, just proceeded on a hunch that turned out to be correct.)

您可能要更新您提交的Radar,以表明这可能是特定于Mojave的.

You may want to update the Radar you filed to indicate that this is probably specific to Mojave.

这篇关于UIDocumentBrowserViewController错误“无法为URL创建urlWrapper".在iOS13模拟器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆