NSTask 启动导致崩溃 [英] NSTask Launch causing crash

查看:34
本文介绍了NSTask 启动导致崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以通过此终端命令导入 XML 文件的应用程序:

I have an application that can import an XML file through this terminal command :

打开/path/to/main\ app.app --args myXML.xml

open /path/to/main\ app.app --args myXML.xml

这很好用,没有问题.我已经使用 Applescript 通过 shell 启动这个命令,它也能正常工作.然而,当尝试使用此代码使用 Cocoa 的 NSTask Launcher 时:

This works great with no issues. And i have used Applescript to launch this command through shell and it works just as well. Yet when try using Cocoa's NSTask Launcher using this code :

NSTask *task = [[NSTask alloc] init];

[task setLaunchPath:@"/usr/bin/open"];

[task setCurrentDirectoryPath:@"/Applications/MainApp/InstallData/App/"];

[task setArguments:[NSArray arrayWithObjects:[(NSURL *)foundApplicationURL path], @"--args", @"ImportP.xml", nil]];

[task launch];

应用程序将启动到初始屏幕,然后在单击下一步按钮或尝试关闭窗口时崩溃.我试过使用 NSAppleScript :

the applications will start up to the initial screen and then crash when either the next button is clicked or when trying to close the window. Ive tried using NSAppleScript with this :

NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"tell application \"Terminal\" do script \"open /Applications/MainApp/InstallData/App/Main\\\\ App.app\" end tell"];

NSDictionary *errorInfo;

[script executeAndReturnError:&errorInfo];

这将启动程序,它也会崩溃,我在 Xcode 调试窗口中收到此错误:

This will launch the program and it will crash as well and i get this error in my Xcode debug window :

12011-01-04 17:41:28.296 LaunchAppFile[4453:a0f] 
Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  
Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
LaunchAppFile: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.

所以通过研究,我想出了这个:

So with research i came up with this :

NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"do shell script \"arch -i386 osascript /Applications/MainApp/InstallData/App/test.scpt\""];

NSDictionary *errorInfo;

[script executeAndReturnError:&errorInfo];

但这会导致与上一条命令相同的结果.关于导致这次崩溃的原因有什么想法吗?

But this causes the same results as the last command. Any ideas on what causes this crash?

推荐答案

检查此处 修复 adobe 错误.我不确定那是问题所在.实际上,我无法使用 open 命令将参数传递给任何东西,因此我无法调查您的问题.

Check here to fix the adobe errors. I'm not sure that's the problem though. Actually I couldn't get the open command to pass arguments to anything so I couldn't look into your problem.

这篇关于NSTask 启动导致崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆