Reputation: 141
how can I generate scripting bridge files at runtime? I want to use scripting bridge to quit an appliction, but that application is not known at compile time.
Upvotes: 1
Views: 1652
Reputation: 925
Scripting Bridge is a compile-time technology. You may be able to generate the header at run-time, but what good would that do to your compiled application?
Try with AppleScript:
NSString* script = [NSString stringWithFormat: @"tell application \"%@\" to quit", appName];
NSAppleScript* as = [[[NSAppleScript alloc] initWithSource: script] autorelease];
[as executeAndReturnError: nil];
Given an app name appName
, you should be able to send it a quit
event quickly and easily.
Upvotes: 0
Reputation: 243146
To create a header file, you need to run two command-line tools—sdef and sdp—together, with the output from one piped to the other. This is the recommended syntax:
sdef /path/to/application.app | sdp -fh --basename applicationName
Upvotes: 4