I would like to create a helper application that has no GUI yet does have access to an app bundle. I was looking at the Xcode command line project templates, but these all just generate executable files. How can I create something like a command line tool that presents no application menu yet provides access to bundle resources in a .app? Am I thinking about this the wrong way?

Peter's answer (use LSUIElement) is probably what you're looking for. Occasionally, I've wanted to create an actual command-line app that also has an app bundle. In case other's come across the same scenario, here's what I've found...

The app bundle is not an executable. The true executable is buried inside: MyApp.app/Contents/MacOS/MyApp is the actual Mach-O executable for an app named MyApp. The standard Xcode templates link applications against AppKit.framework and have a main.m that defines the main() function for the executable that starts an NSApplication instance. You can put any executable in an app bundle, however, including a console-only app. Just replace the main() function in main.m in the application template with your console apps main() function and remove AppKit.framework from the app's linked frameworks.

If you want, you can replace main.m with a main.c that declares a main function if you want to avoid Objective-C entirely (though there's nothing necessarily Objective-C specific in main.m if you replace the contents of the main() function).

To run your application from the console, you have to specify the actual executable, not the app bundle, so you'd have to type MyApp.app/Contents/MacOS/MyApp at the command line. When I've used app bundles for console apps (to provide linked frameworks, resources, etc.), I often create a symlink to the executable and put the symlink in /usr/local/bin (or somewhere else on the path) during installation or first run.

All true enough, but Peter's answer may be closer to what the developer is trying to achieve.
–
KenFeb 9 '10 at 9:53

1

@Ken: Agreed. The asker is probably looking for a LSUIElement app. I've found occasion to have a console-only app that uses an app bundle, however. Just in case it's useful to others, I'll leave this answer up.
–
Barry WarkFeb 9 '10 at 16:11

@Matt - Agreed; use LSUIElement. I'll edit my answer to make that clear and that the info is really only if you want to create a command-line app with an app bundle (yes, I've had to in the past).
–
Barry WarkFeb 12 '10 at 0:49