Results 1 to 10 of 10

Thread: Distributing Program with its own File Structure in MacOS Application Bundle

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Distributing Program with its own File Structure in MacOS Application Bundle

    So, hello again, it's time for a new thread, this time regarding this wonderful thing "application bundles" on MacOS.

    I already know how an app bundle is structured. Usually, the binary is inside the "MacOS" folder and all graphics, sounds etc. are in the "Resources" folder.

    The problem is that my game "LambdaRogue" expects all its graphics, sounds etc. in subfolders inside the game folder, i.e.:

    Code:
    LambdaRogue
    |
    +--graphics folder
    +--sound folder
    +--music folder
    +--docs folder
    +--data folder
    +--saves folder
    |
    +--binary file
    +--"lambdarogue.cfg" textfile

    I first tried to put all these folders and the cfg file into the "MacOS" folder of the application bundle as well:

    Code:
    LambdaRogue.app
    |
    +--Contents
       +--MacOS
          +--graphics
          +--sound
          ...etc...
          binary
    This did not work, though. So I thought its best to put all these things into the "Resources" folder and write a little shell script which would be executed after

    Code:
    #!/bin/sh
    cd "/Applications/LambdaRogue.app/Contents/Resources"
    ./fprl
    So I had the following structure:

    Code:
    LambdaRogue.app
    |
    +--Contents
       +--Resources
       |  +--graphics folder
       |  +--sound folder
       |  +--data folder
       |  +--docs folder
       |  +--saves folder
       |  +--binary file
       |
       +--MacOS
          +--startup shell script (changes into resources folder and executes binary file)
    I also changed the "executable" entry in the plist file of the app accordingly. The script is correctly executed, the binary "fprl" is started by the script, but it stops with the error message that it does not find its config file.

    So obviously changing into the directory will all my resources was not enough, and this again is then something that works different from Windows and Linux.

    (The script works if I call it directly from terminal).

    So what do I need to do to make this app bundle work? Do I need to change the source code of the game itself in a way that it does not look for its files in its own directory anymore, but instead in ../Resources ? Or is there an easier way?


    Edit: Hm. Making the game looking for its resources in the Resources folder does also only work when the binary is started from a terminal. (I put a "../Resources/" before all filenames referred to in the game). However, it does not work when started by double clicking the app icon.

    Edit: I now double clicked the binary from within the app bundle. Here, a terminal window opened which showed me (due to some debug messages in my game) that it was started with the working directory set to my home directory. I then included a SetCurrentDir call in my binary that set the working directory correctly.

    But again, this had no effect. Double clicking the bundle brought nothing, but double clicking the binary from inside the bundle started the game.

    (Remark: I know that I simply could create a zip and put everything inside and tell the users to start the game from within the terminal, i.e. I could simply distribute the game the Linux way. But app bundles are so elegant.)
    Last edited by Mario Donick; 09-01-2011 at 05:04 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •