我的应用程序需要 dylib 文件位于/usr/lib/中。如果不存在,应用程序会将 dylib 从应用程序资源目录复制到/usr/lib/。为此,我使用了一个辅助工具,它调用/usr/bin/sudo。
尽管此应用程序在许多系统上都能正常工作,但我刚刚收到一份错误报告,其中该应用程序显然无法找到帮助工具的启动路径。
有谁知道为什么这可以在许多系统上运行,但只有一个系统会崩溃?
代码:
if (!libraryExists) {
NSLog(@"dylib does not exist at usr/lib. Launching helper tool to duplicate dylib in application directory\n");
NSArray *args = [NSArray arrayWithObjects:helperToolPath, @"setup", nil];
[NSTask launchedTaskWithLaunchPath:helperToolPath arguments:args];
}
日志:
2012-01-11 09:53:59.008 Application[1860:b07] 辅助工具路径设置为:/Users/xx/Downloads/Application.app/Contents/Resources/HelperTool
2012-01-11 09:54:00.585 应用程序[1860:b07] dylib 在 usr/lib 中不存在。启动辅助工具从应用程序目录复制 dylib
2012-01-11 09:54:00.587 应用程序[1860:b07]启动路径无法访问
最佳答案
如果用户不在管理员组中,他们可能无权运行您的帮助应用程序。您可以创建一个没有管理员权限的新用户帐户来测试这一理论。
关于objective-c - NSTask 'launch path not accessible',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8829658/