gpt4 book ai didi

macos - 如何在沙盒应用程序中添加快速查看生成器?

转载 作者:行者123 更新时间:2023-12-03 16:23:41 27 4
gpt4 key购买 nike

我已经为我的应用程序创建了一个 QuickLook 生成器,并使用以下代码将 QuickLook 生成器复制到此位置 Containers/com.Aravindh.EgApp/Data/Library/QuickLook/QuickLookGenerator.qlgenerator .

    NSString *path1 = [[NSBundle mainBundle] pathForResource:@"QuickLookGenerator" ofType:@"qlgenerator"];
NSError *error;
NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask];
NSString *librayPath = [[paths objectAtIndex:0] path];
librayPath = [NSString stringWithFormat:@"%@/Quicklook/QuickLookGenerator.qlgenerator",librayPath];
if(![[NSFileManager defaultManager] fileExistsAtPath:librayPath]) {
[[NSFileManager defaultManager] copyItemAtPath:path1 toPath:librayPath error:&error];
}

但我收到此错误:

Error Domain=NSCocoaErrorDomain Code=513 "“QuickLookGenerator.qlgenerator” couldn’t be copied because you don’t have permission to access “QuickLook”." UserInfo=0x101518250 {NSSourceFilePathErrorKey=/Users/Aravindh/Desktop/EgApp/EgApp/build/Release/EgApp.app/Contents/Resources/QuickLookGenerator.qlgenerator, NSUserStringVariant=(
Copy
), NSDestinationFilePath=/Users/Aravindh/Library/Containers/com.Aravindh.EgApp/Data/Library/Quicklook/QuickLookGenerator.qlgenerator, NSFilePath=/Users/Aravindh/Desktop/EgApp/EgApp/build/Release/EgApp.app/Contents/Resources/QuickLookGenerator.qlgenerator, NSUnderlyingError=0x10154dbb0 "The operation couldn’t be completed. Operation not permitted"}

我是否必须在 Entitlementes.plist 中提及任何内容?如何在沙盒环境中安装QuickLookGenerator?

最佳答案

您无需将 QuickLook 插件复制到 ~/Library/QuickLookIf it's in YourApp.app/Contents/Library/QuickLook/然后系统将使用它 - 这适用于沙箱,因为除了将插件与您的应用程序捆绑在一起之外,您不需要执行任何操作。

关于macos - 如何在沙盒应用程序中添加快速查看生成器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13948437/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com