简体   繁体   English

FinderSync扩展运行时错误:由于您无权查看该文件,因此无法打开该文件

[英]FinderSync Extension runtime error: The file couldn’t be opened because you don’t have permission to view it

I'm writing a FinderSync extension that places an item in the context menu. 我正在编写一个FinderSync扩展,将项目放在上下文菜单中。 When I right-click, I want the title of the menu item to change based on the selected file's contents. 当我右键单击时,我希望菜单项的标题根据所选文件的内容进行更改。 However, when I try to read the contents using Data(contentsOf: selectedUrl) , it throws the following error: 但是,当我尝试使用Data(contentsOf: selectedUrl)读取内容时,它会抛出以下错误:

Error Domain=NSCocoaErrorDomain Code=257 "The file “Some File.png” couldn't be opened because you don't have permission to view it." 错误域= NSCocoaErrorDomain代码= 257“无法打开文件”Some File.png“,因为您无权查看它。” UserInfo={NSFilePath=/Users/Shared/MySyncExtension Documents/Some File.png, NSUnderlyingError=0x61800004cf00 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} UserInfo = {NSFilePath = / Users / Shared / MySyncExtension Documents / Some File.png,NSUnderlyingError = 0x61800004cf00 {Error Domain = NSPOSIXErrorDomain Code = 1“不允许操作”}}

This does not change if I add or remove sandboxing. 如果我添加或删除沙盒,这不会改变。


Prior Research 先前的研究

The issue is that the Sandbox is preventing file access to the file, and thus your app cannot open it. 问题是Sandbox阻止文件访问该文件,因此您的应用程序无法打开它。

Read and Write access for FinderSync extension in a sandboxed environment 沙盒环境中FinderSync扩展的读写访问权限

Even though the Finder Sync App Extension is granted "User Selected File" Sandbox File Access, the files accessed by the user via right-click seemingly do not count as being "user-selected". 即使Finder Sync App Extension被授予“用户选择文件”沙盒文件访问权限,用户通过右键单击访问的文件看起来也不算“用户选择”。

It may be possible to guide the user to select a root directory via an NSOpenPanel via Powerbox, after which all subdirectories can be accessed via a security-scoped bookmark . 可以引导用户通过Powerbox通过NSOpenPanel选择根目录,之后可以通过安全范围的书签访问所有子目录

Using a Temporary Exception entitlement is also a possibility, but will cause App Review problems: 使用临时例外权利也是可能的,但会导致App Review问题:

Is there any way to give my sandboxed Mac app read only access to files in ~/Library? 有没有办法让我的沙盒Mac应用程序只读访问〜/ Library中的文件?

Please duplicate my Apple bug report requesting this behavior be allowed: 请复制我的Apple错误报告,请求允许此行为:

Finder Sync App Extension selectedItemURLs() should receive "User Selected File" Sandbox file access. Finder Sync App Extension selectedItemURLs()应该接收“用户选择的文件”Sandbox文件访问权限。

rdar://42874694 rdar:// 42874694
https://openradar.appspot.com/radar?id=5063363058991104 https://openradar.appspot.com/radar?id=5063363058991104

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法检索文件,错误:由于您无权查看该文件,因此无法打开该文件 - Cannot retrieve file, error: The file couldn’t be opened because you don’t have permission to view it 文件“MyApp”无法打开,因为您无权查看错误(Xcode 11) - The file “MyApp” couldn’t be opened because you don’t have permission to view it error (Xcode 11) 文件无法打开,因为您没有权限查看它错误 - File couldn’t be opened because you don’t have permission to view it error 文件“***.app”无法打开,因为您没有查看它的权限 - The file “***.app” couldn’t be opened because you don’t have permission to view it 获取文件“xxx”无法打开,因为您在导入时没有查看它的权限 - Getting The file 'xxx" couldn't be opened because you don't have permission to view it when importing 无法运行“无法打开文件“ ***。app”,因为您没有查看权限” - Unable to run “The file “***.app” couldn’t be opened because you don’t have permission to view it” 由于您无权查看文件“ IMG_0001.JPG”,因此无法打开 - The file “IMG_0001.JPG” couldn’t be opened because you don’t have permission to view it 由于您无权查看文件“ xxx.mp4”,因此无法打开 - The file “xxx.mp4” couldn’t be opened because you don’t have permission to view it “无法打开该文件,因为您没有查看它的权限。” 对于 iCloud 视频 - "The file couldn’t be opened because you don’t have permission to view it." for iCloud Videos 无法打开文件“ ”,因为您没有查看它的权限 - The file “ ” couldn’t be opened because you don’t have permission to view it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM