views:

238

answers:

4

I have an application I want to bundle (with some additional files) together inside a wrapper application.

Literally the only thing I want to do is have the wrapper application launch a resource file (i.e. as if I'd typed:

/path/to/Resources/Bundled.app/Contents/MacOS/executable

into the terminal.

Make sense? I thought this should be simple, but I caouldn't find a simple way to do this-- my cocoa programming is limited, to say the least.

Thanks in advance!

A: 

I have a blog post up on this: Turn any shell script into a double-clickable app. The entry mentions "start with an empty app bundle"... which you can get by using the Pashua tool mentioned, if I remember correctly...

RyanWilcox
thanks i will take a look
Jack
+1  A: 

One way, if the wrapped “application” is just a shell script or something, is Platypus.

If it's an actual application (.app bundle), why does app A do nothing but launch app B? Why have app A at all?

Peter Hosey
For two reasons- first because app B has several resources which it requires to be in the same folder as the app itself (I have no control over this behaviour, this is 3rd-party stuff)-- this way I can bundle them all together as a single package.Secondly because at some point in the future I will probably want the wrapper to do something a little bit smarter, like choose between multiple apps.
Jack
You may want to do that yourself in Xcode, then.
Peter Hosey
+1  A: 

Your outer program can use NSBundle to locate the inner program within the outer program's bundle.

To run the inner program: If it's an application, use Launch Services or NSWorkspace; if it's a command-line tool, use NSTask.

Peter Hosey
thanks-- that makes sense
Jack
A: 

Just for the sake of posterity (and if it helps anyone else, here is the full code I used (inside the AppDelegate.m file):

NSString *appName = @"";
NSString *bundledApp = [[NSBundle bundleWithPath:[[NSBundle
                                                           mainBundle] pathForResource:appName ofType:@"app"]]
                          bundlePath];
NSWorkspace *launchApp = [[NSWorkspace alloc] init];
NSLog(@"Launching %s", bundledApp);
[launchApp launchApplication:bundledApp];
[launchApp release];

// Make Launcher terminate (if it serves no other purpose)
[NSApp terminate:nil];
Jack