2

サンドボックスで実行される ObjectiveC アプリから iTunes を実行しようとしています。Apple のドキュメントには、「NSTask クラスで作成された子プロセスは、親アプリのサンドボックスを継承する」と記載されています。その結果、iTunes を実行すると、いくつかの許可エラーがポップアップ表示され、iTunes が閉じられます。NSWorkspace メソッドを使用して実行すると、クラッシュせず、サンドボックスの外で実行されているように見えます。DYLD_INSERT_LIBRARIES を使用して、起動時に動的ライブラリを挿入する権限があることを意味しますか? ここにいくつかのコードがあります:

NSString* appPath = @"/Applications/iTunes.app";
// Get application URL
NSBundle *targetBundle = [NSBundle bundleWithPath:appPath];
NSURL *applicationURL = [targetBundle executableURL];

NSString* libPath = [NSHomeDirectory() stringByAppendingPathComponent:@"myLib.dylib"];
// Environment setup
NSDictionary *config = nil;
NSDictionary *env = [NSDictionary dictionaryWithObject:libPath forKey:@"DYLD_INSERT_LIBRARIES"];

NSNumber *arch = [NSNumber numberWithInt:(int)NSBundleExecutableArchitectureI386];
config = [[NSDictionary alloc] initWithObjectsAndKeys:env, NSWorkspaceLaunchConfigurationEnvironment, 
                                                      arch, NSWorkspaceLaunchConfigurationArchitecture, nil];

// Launch application
[[NSWorkspace sharedWorkspace] launchApplicationAtURL:applicationURL
                          options:0 
                    configuration:config 
                            error:nil];

[config release];

上記のコードをサンドボックスで実行すると、iTunes は lib なしで起動します。なにか提案を?

ありがとう、ヴラド。

4

0 に答える 0