You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SentTransferredFile所需Info.plist配置问题及官方文档查询

问题:FileRepresentation + SentTransferredFile 导出时,Save to Files 功能异常

场景复现

实现Transferable协议的代码如下:

extension LoanXLSX: Transferable {
    static var transferRepresentation: some TransferRepresentation {
        FileRepresentation(exportedContentType: .loan) { document in
            // Generate an XLSX document and retrieve its path...
            let url = URL(filePath: path)
            return SentTransferredFile(url)
        }
    }
}

多数分享渠道可正常工作,但使用Save to Files时,系统弹出空白文件浏览器面板后直接关闭,应用日志输出:

cancelled request - error: The operation couldn’t be completed. Invalid argument

控制台中SaveToFiles进程关联错误:

completing requestwith error: Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument"

解决方案

开启以下任意一组配置即可修复问题:

  • 同时开启LSSupportsOpeningDocumentsInPlace与UIFileSharingEnabled(在Info.plist中添加对应布尔键并设为YES)
  • 仅开启UISupportsDocumentBrowser(在Info.plist中添加对应布尔键并设为YES)

相关资源参考

苹果官方文档中,与该问题相关的核心配置说明:

  • UIFileSharingEnabled:控制应用是否支持iTunes文件共享,同时影响系统文件浏览器的交互权限
  • LSSupportsOpeningDocumentsInPlace:允许应用直接打开沙盒外的文档,是文档浏览器交互的基础配置之一
  • UISupportsDocumentBrowser:声明应用支持文档浏览器框架,开启后会自动赋予系统文件交互的必要权限

相关WWDC视频可关注:

  • WWDC 2017 Session 226: Introducing the Document Browser
  • WWDC 2020 Session 10652: Advances in App Clip Experiences(涉及文件交互权限部分)
  • WWDC 2022 Session 10062: Share and collaborate with document-based apps

内容的提问来源于stack exchange,提问作者lucasgladding

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 23:31:00