在沙盒Mac应用程序中使用xattr更改文件元数据



我正在尝试删除"com.apple. com. "

中文件中的"隔离"属性

~/图书馆/集装箱/……/图书馆/应用支持。

在控制台中使用NSTask和xattr会导致"Operation not allowed "消息。作为第二个选项,我使用removexattr()尝试了标题xattr.h。

我还尝试将LSFileQuarantineEnabled添加到Info.plist。在终端中手动调用xattr可以工作。

似乎沙箱阻止xattr使用Objective-C删除属性

在沙盒应用程序中运行helper二进制文件…

第一次测试:

  1. 使用"Keychain Access"创建证书
    1. "证书助手">"创建证书…"
    2. 命名它…
    3. 覆盖默认设置
  2. 使用
  3. 签名您的助手二进制文件(更新程序)codesign -s <certificate A> <binary>
  4. 复制二进制文件到你的项目
  5. 检查它是否链接在"Build Phases">"Copy Bundle Resources"
  6. 转到产品>存档
    1. 分发…
    2. 导出为应用
    3. 使用您的签名身份

如果你想发送到Mac App Store,请使用正确的证书。

我用来启动/调用helper二进制文件的代码如下:
NSString * resourcePath = [[NSBundle mainBundle] resourcePath];
NSTask *testbin = [[NSTask alloc] init];
NSString * path = [resourcePath stringByAppendingString:@"/testbin"];
[testbin setLaunchPath:path];
[testbin launch];
[testbin waitUntilExit];

无需复制或移动文件;-)

最新更新