I am developing a multi-platform presentation application which consists of two parts: An editor part and a viewer part. Both parts are developed as separate programs. The user edits the individual slides using the editor and the editor then launches the viewer whenever the user wants to see his presentation.
On Windows the editor can simply run the viewer by doing a ShellExecute(). On Linux systems the editor could just fork() the viewer but on Mac OS X this looks like it could get complicated because of the infamous application bundle concept.
I'm wondering how this problem should be solved on Mac OS X.
Is it possible to have multiple applications inside a single application bundle or do I have store the editor and viewer components as separate application bundles?
Also, how am I supposed to pass information from the editor to the viewer application? i.e. the viewer needs to know which file to show. On Windows and Linux I can just pass this as command line arguments to the WinMain() or main() function. On OS X it looks like LSOpenApplication() could do the job but this is now deprecated. And I don't know if LSOpenApplication() can open applications inside the same application because I don't know whether that is even possible...
Could somebody shed some light onto this topic? Thanks!
Is it possible to have multiple applications inside a single application bundle or do I have store the editor and viewer components as separate application bundles?
Yes, and yes.
Each application must be its own bundle. But you're free to include bundles inside your bundles. This isn't even that uncommon. Take a look inside of iTunes for instance:
/Applications/iTunes.app/Contents/MacOS$ ls -l
total 116816
-rwxr-xr-x 1 root wheel 56643216 Oct 15 09:29 iTunes
-rwxr-xr-x 1 root wheel 42608 Oct 16 20:31 iTunesASUHelper
drwxr-xr-x 3 root wheel 102 Oct 16 20:33 iTunesHelper.app
-rw-r--r-- 1 root wheel 3617952 Oct 16 20:31 libgnsdk_dsp.3.06.0.dylib
-rw-r--r-- 1 root wheel 328928 Oct 16 20:31 libgnsdk_link.3.06.0.dylib
-rw-r--r-- 1 root wheel 3831312 Oct 16 20:31 libgnsdk_manager.3.06.0.dylib
-rw-r--r-- 1 root wheel 1511792 Oct 16 20:31 libgnsdk_musicid.3.06.0.dylib
-rw-r--r-- 1 root wheel 655328 Oct 16 20:31 libgnsdk_submit.3.06.0.dylib
See how iTunesHelper.app
lives inside of iTunes.app
? And also the commandline tool iTunesASUHelper? This is fine and normal. Just move it there during the copy files build phase.
A common tool for launching apps now is NSWorkspace
. For your particular case, you probably want openFile:withApplication:
. You may also want to look at XPC, however, to see if it meets your needs better. It allows much easier inter-process communication, though I find it's best for helper services rather than full GUI apps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With