この端末コマンドを使用して XML ファイルをインポートできるアプリケーションがあります。
/path/to/main\ app.app --args myXML.xml を開く
これは問題なくうまく機能します。そして、Applescriptを使用してシェルからこのコマンドを起動しましたが、同様に機能します。それでも、次のコードを使用して Cocoa の NSTask Launcher を使用しようとすると:
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 を使用してみました:
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 デバッグ ウィンドウに次のエラーが表示されます。
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.
だから研究で私はこれを思いついた:
NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"do shell script \"arch -i386 osascript /Applications/MainApp/InstallData/App/test.scpt\""];
NSDictionary *errorInfo;
[script executeAndReturnError:&errorInfo];
しかし、これは最後のコマンドと同じ結果を引き起こします。このクラッシュの原因についてのアイデアはありますか?