使用COMMAND LINE帮助程序的沙盒OSX应用程序提供"无法获取根路径"

Edd*_*die 11 macos code-signing sandbox mac-app-store

我正在构建一个与命令工具'unrar'捆绑在一起的Mac应用程序来解开一些文件.该应用程序是沙盒.

在xcode中,我将unrar命令工具复制到应用程序的Resourse文件夹(带有名为'exec'的子路径):

复制文件: 目标:资源 - 子路径:执行

在复制阶段之后,我执行运行脚本来设置权利和代码签名,如下所示:

运行脚本: Shell:/ bin/sh

LOCATION="${BUILT_PRODUCTS_DIR}"/"${CONTENTS_FOLDER_PATH}"
IDENTITY="3rd Party Mac Developer Application: CompanyName."
codesign -f -s "$IDENTITY" --entitlements"/<path>/unrar.entitlements" "$LOCATION"/Resources/exec/unrar
Run Code Online (Sandbox Code Playgroud)

在应用程序本身中,我使用NSTask来执行unrar命令:

NSString *filePath = [[NSBundle mainBundle] pathForResource:@"unrar" ofType:@"" inDirectory:@"exec"];

NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:filePath];
[task setArguments:[NSArray arrayWithObjects:@"e", rarfilepath,extractpath, nil]];
[_task launch];
Run Code Online (Sandbox Code Playgroud)

unrar.entitlements包含:

<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.inherit</key>
<true/>
Run Code Online (Sandbox Code Playgroud)

运行应用程序时,一切正常,文件被提取.

但是......然后当我检查系统日志时,我看到以下消息:

secinitd [332]:unrar [94747]:无法获取主可执行文件包的根路径:/Applications/App.app/Contents/Resources/exec/unrar

当我不运行上面的运行脚本时,该消息确实消失,但是然后没有为'unrar'命令工具设置权利并且Sandboxing失败.

我现在已经听了三天听到这个消息意味着什么,以及如何解决它,但我没有想法.

搜索谷歌或stackoverflow也没有帮助.

请有人帮我解决这个问题.

谢谢你,安德烈.

(抱歉所有文字,但我不允许发布图片.)

小智 0

我相信 unrar 可执行文件必须位于

MySandboxApp.app/Contents/Helpers/unrar
Run Code Online (Sandbox Code Playgroud)

资源文件夹仅限于不可执行的内容。