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

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

问题描述

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

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

打开/路径/要/主\\ app.app --args myXML.xml

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

这完全没问题的伟大工程。我已经使用AppleScript的推出经过加壳这个命令和它的作品一样好。然而,当尝试使用Cocoa的NSTask启动使用该code:

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];

这将启动程序,它会崩溃,以及和我在我的X code调试窗口得到这个错误:

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?

推荐答案

这里修复土坯错误。我不知道这就是问题所在,但。其实我不能让开命令参数传递到任何东西,所以我不能看着你的问题。

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天全站免登陆