MacOS Binaries

Discuss any general programming issues here
nexus
Posts: 133
Joined: Sun Mar 07, 2010 11:54 am

MacOS Binaries

Post by nexus »

When programming an application with Hollywood that also load some resource files like text, pictures or fonts. Where do i have to store them such that a script compiled as MacOS binary can find them?

e.g.
<project-dir>/
-->pics/
-->fonts/
-->MyProgram.hws


When I compile a MacOS binary, i get a directory with several subdirectories:
<project-dir>/
-->MyProgram.app/
-->-->Contents/
-->-->-->Info.plist
-->-->-->MacOS/
-->-->-->-->MyProgram
-->-->-->Resources/
-->-->-->-->MyProgramm.icns

When I now start the MacOS binary, it can't find the pics, fonts, etc in <project-dir>/ (which works fine with Windows and AmigaOS binaries).
So, my question is: Where do I have to copy the directories "fonts/", "pics/", etc to such that the MacOS executable can find them over a relative path, e.g. "pics/mypic.png"?

Actually, I already asked that question on the HW mailing-list but got no answer so far. I guess, meanwhile the forum is more active than the mailing list?

Thanks,
nexus
jalih
Posts: 276
Joined: Fri Jun 18, 2010 8:08 pm
Location: Finland

Re: MacOS Binaries

Post by jalih »

Just put those directories and files in the Resources folder.

Here is some simple game as an example
nexus
Posts: 133
Joined: Sun Mar 07, 2010 11:54 am

Re: MacOS Binaries

Post by nexus »

Thanks, I will test that.

Does this also work with the font directory? In hollywood i specified the open/true type font as a relative path:
"fonts/myfont.otf".

My progrom also writes some temporary data to "data/temp.dat", does this also work by just moving the "data" dir into the "Resources"-dir?

Thanks,
nexus
nexus
Posts: 133
Joined: Sun Mar 07, 2010 11:54 am

Re: MacOS Binaries

Post by nexus »

Oh, and can I rename the MacOS binary-directory to some new name after it has been created?
I guess, i also have to rename Content/MacOS/<program_name> and Content/Resources/<program_name>.icns to the new name?

Thanks for your help. MacOS is an unknown beast to me :)

nexus
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: MacOS Binaries

Post by airsoftsoftwair »

nexus wrote: Does this also work with the font directory? In hollywood i specified the open/true type font as a relative path:
"fonts/myfont.otf".
Yes. On Mac OS X, all non-qualified path specifications are relative to the "Resources" directory inside the app bundle.
nexus wrote: My progrom also writes some temporary data to "data/temp.dat", does this also work by just moving the "data" dir into the "Resources"-dir?
Yes.
nexus wrote:Oh, and can I rename the MacOS binary-directory to some new name after it has been created?
I guess, i also have to rename Content/MacOS/<program_name> and Content/Resources/<program_name>.icns to the new name?
Yes, and you also need to adapt the Info.plist file inside the app bundle. Just search & replace for all instances of the executable name and replace them with the new desired name. Then it should work :)
gerograph
Posts: 39
Joined: Thu Mar 04, 2010 9:38 pm

Re: MacOS Binaries

Post by gerograph »

One more question concerning this topic:

I have images situated inside "/Imagedir", my "app" bundle sits in the same dir !

../imagedir/show.app

therefore the images to be displayed (via show.app) are not (!) situated inside "Resource" subdir. How can I "go two steps back" from "start/reference dir" ?

Ideas wellcome !
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: MacOS Binaries

Post by djrikki »

I've had no luck getting MacOS binaries to run under Snow Leopard. Perhaps someone can elaborate what is meant by changing the file attribute to executable or something or other mentioned in the Amigaguide.

Personally I don't plan to release anything from the MacOS platform, but on the MacOS side would I be expected to open up Applications/Utilities/Terminal and chmod the file or something? Or do I Show Package Contents and do something in there itself.

A step-by-step guide to how it is done correctly might be worthwhile inserting into the Amigaguide to explain the process further for those interested.
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
gerograph
Posts: 39
Joined: Thu Mar 04, 2010 9:38 pm

Re: MacOS Binaries

Post by gerograph »

@djrikki
Well I am not sure wether you still have to set "executable" bit or not... (Hollywood 4.7). However my mac (Intel) binaries recently tested by "Samurei_Crow" did not have to been set to "executable" (see this thread http://www.amigans.net/modules/xforum/v ... 17&forum=7about "Addslideshow" Project). There is one problem though:

On Windows and Amiganoid Systems the files needed for your Hollywood Presentation/Program should be situated in the same directory where your compiled HW Presentation sits (lets call it progdir). This is different on the MAC site: If you compile for MAC you get a "app" package, which is basically a directory:

mypresentation.app

files to be used by this hollywoodpresentation (mypresentation) must be situated in:

../mypresentation.app/Contents/Resources

For my slideshowplayer (part of "Addslideshow") this means all images have to sit inside this directory. Which has to be changed in my case...
However, if you still have to set the executable bit here is an (german) instruction on how to install e.g. KoKa (mapcoordinate proggy):
http://www.bboah-works.de/phpbb33/downl ... &df_id=402

This is the part I am refering to:
MacOS

(Falls eine MacOS Version erhältlich ist.)

Es kann sein, dass nach dem Entpacken des Archivs und dem Verschieben
ins Programm Verzeichnis "KoKa" nicht startet. In diesem Fall müssen
Sie mit Hilfe des "Terminal" die Attribute noch auf Ausführbar setzen.


Entpacken Sie die Zip-Datei und ziehen den Ordner "KoKa"
ins Verzeichnis "Programme".

Öffnen Sie im Ordner "Programme > Dienstprogramme" "Terminal"

Tippen Sie nun folgendes ein, ohne die Eingabetaste (Return
oder Enter) zu drücken:

chmod uga+rwx



Fügen Sie nach dem rwx noch ein Leerzeichen ein.

Packen Sie im Finder mit der Maus das Icon vom Ordner
"KoKa" und ziehen Sie es über das Terminal.

Wenn das Fenster innen einen farbigen Rand erhält, lassen Sie
das Icon los. Jetzt erscheint der Pfad im Terminal.

Löschen Sie nun am Ende vom Pfad das Leerzeichen und tippen
jetzt folgendes ein:

/contents/MacOS/KoKa

Kontrollieren Sie jetzt unbedingt ihre Eingabe. Hat es
zwischen chmod und uga+rwx ein Leerzeichen? Und zwischen
uga+rwx und dem Dateipfad? Auch dort ein Leerzeichen eingetippt?
Wenn etwas nicht zutrifft, korrigieren Sie es.

Wenn Sie jetzt sicher sind, dass Sie alles richtig eingetippt
haben, drücken Sie die Eingabetaste (Retrun oder Enter).

Und jetzt testen Sie mal, ob KoKa läuft. Falls Ja, schliessen
Sie das Terminal. Wenn Nein, ziehen Sie jemanden zu Rate, der sich
mit dem Terminal auskennt (sei es ein Bekannter oder in einem Forum
wie z.B. http://www.macforum.ch).


Diese Mac Anleitung wurde mit Hilfe von SecretSurfer aus dem
http://www.macforum.ch erstellt.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: MacOS Binaries

Post by airsoftsoftwair »

@djrikki:
You just need to modify the flags of the main executable that is inside the application bundle. This executable is always located in AppBundle/Contents/MacOS. So if you compile a script as "TestProgram", then you need to do the following:

Code: Select all

chmod +e TestProgram.app/Contents/MacOS/TestProgram
Or just use Finder or a file manager to change the flags. You don't necessarily have to do this via Terminal.
djrikki
Posts: 682
Joined: Wed Apr 06, 2011 12:26 am

Re: MacOS Binaries

Post by djrikki »

Hello, hello

If I want to save a brush to the user's desktop on MacOS x86 what path should I specify? Given that the application can a) be installed anywhere and b) we don't know the user's account name. I already have the brush saving in a saves folder inside the bundle, but of course that is no good for the end user.

Also, do HW applications run on Windows 7? If yes, again how would I save to the desktop? Do I have to mess about with the stupid Windows registry?
Evolve - Rapid GUI Development tool for MUI Royale and RapaGUI
http://myevolve.wordpress.com
Post Reply