Multiple Apps within a package?

Discussion in 'Mac Programming' started by RobQuads, Jul 9, 2015.

  1. RobQuads macrumors regular

    Joined:
    Jul 11, 2010
    #1
    I (we) am in the process of porting our day job application onto Mac. We've done most of the porting and got the product it self building so I am looking at the packaging step. Currently we have a single build output which includes 2 applications, a runtime and toolkit. I've been able to create a .app file for the runtime variant and the toolkit separately but I am not sure what is the best way to have two launch able apps? from the same package i.e. I have a file structure something like

    Root
    common_files
    toolkit
    runtime

    The toolkit is launched by running a command in the toolkit directory and the runtime is launched by running a command in the runtime directory.

    Whats the best way to package this up? I'm looking to have a simple drag and drop style install that you can with an app.

    Thanks for any advice. Fingers crossed this side project will get there in the end and I will be able to run the product on my laptop natively.
     
  2. rthpjm, Jul 9, 2015
    Last edited: Jul 9, 2015

    rthpjm macrumors 6502

    rthpjm

    Joined:
    Jan 31, 2011
    Location:
    U.K.
    #2
    Hello RobQuads,

    There is no single right answer to this question. I will try to help....

    It all depends on your expectations for user experience (UX). You mention a single drag/drop install so I'll focus on that. The simplest drag and drop install will have a single app to be dropped into the Applications folder.

    For me, this implies that you must choose one of your apps as the "primary" app, relegating the other app to "secondary" status. You know your apps and the workflow best. I would choose the primary app as the one with the most user interface (UI) elements on the basis this would be the one that end users will probably interact with the most.

    You don't mention whether one or both of your apps have a user interface (UI). If only one has a UI the choice of primary is obvious.

    Now Mac OS X applications are "bundles" of folders and files. The Finder understands these app bundles and treats them as a single item. An application bundle has a fairly distinct folder/file layout. Assuming you are building your app with XCode then the primary app will be a folder, right-click on it, choose 'Show Package Contents'. This will open the folder in a new window, you will see a single folder named Contents, open this. You should now see a typical set of folders and files. I won't go into detail for them all, I'll just mention the MacOS folder which contains the actual binary executable file that is your application. Take a note that there is also a Resources folder here. It contains a bunch of stuff that your primary app will utilise, the GUI definition, images, localised text to name a few.

    Now what to do with your secondary app? Techniques differ, and the choice is yours. Typically secondary (or subsidurary) apps are copied (or embedded) into the primary app folder structure, most typically by simply copying it into the Resources folder of the primary app. If you do this you will probably need to add a method of launching the secondary app from within the primary app (I would use a menu item and/or a UI button). The lowest common method of launching the secondary app is to figure out the path to the primary app binary image (typically /Applications/yourapp.app/Contents/MacOS/yourapp) then make a system call to launch your secondary app by path (perhaps using relative path naming ../Resources/otherapp.app/Contents/MacOS/otherapp, or the full path). I say "figure out the path" because if you give users a drag and drop install approach then they can choose to drop it anywhere. Take a look at:
    https://developer.apple.com/library/mac/documentation/Carbon/Reference/LaunchServicesReference/

    If you're already building both apps successfully, it's fairly simple to add a post-build task to your secondary app that will copy it to the correct location inside the primary app bundle.

    (As I said earlier there are many other options, but they're beyond my desire to write a post that long).

    Have fun...
     
  3. RobQuads thread starter macrumors regular

    Joined:
    Jul 11, 2010
    #3
    Thanks for the reply. I suspected as much so its good to know I am not missing anything obvious
     
  4. rthpjm macrumors 6502

    rthpjm

    Joined:
    Jan 31, 2011
    Location:
    U.K.
    #4
    No problems!

    You might find that LSCopyApplicationURLsForBundleIdentifier will help. Assuming your secondary app has been configured with a bundle identifier that is distinct, then the OS will be able to find it anywhere (in theory, even if it is embedded inside the folder structure of your other app)

    https://developer.apple.com/library...func/LSCopyApplicationURLsForBundleIdentifier
     

Share This Page