Compilación de la aplicación Mac OS X en lugar de la consola

I have a port of my application, a game, running on Mac OS X. I build with make, and only added a few .mm files to access the necessities from NSApplication, NSWindow and NSOpenGLView.

  1. How do I "convert it" into a proper App as opposed to the current console form? Do I bundle it with something, if so how? Or is it some type of linker setting (as in Windows)? Do I have to build using XCode?
  2. Currently I just "tick" the system, i.e. poll it for events rather than utilizing OS X message pump properly. Could you point me to some basic sample or tutorial which shows me how to do it properly, while still being able to "tick" my own stuff at a fixed frame rate? I say "sample or tutorial", since I am blind when it comes to documentation.


preguntado el 08 de enero de 11 a las 22:01

2 Respuestas

For the creation of a proper Mac application, you'll have to create a Mac OS X bundle. You can find the great documentation on the Apple site, Aquí. You can create them with standard tool (I did write a small python script to create a bundle from a simple .ini file that describe files to pack, and how to construct the Info.plist de archivo).

Basically, an application bundle is just a regular directory with a .app extension, and a fixed structure. The following file are required:
  + Contents/
    + MacOS/
    | + <Executable>
    + Resources/
    | + <Icon>
    + Info.plist

La Info.plist file is a standard property list file (either in XML or in the old format), that indicate what is the name of the executable file (CFBundleExecutable), what is the name of the icon file (CFBundleIconFile), the bundle type (CFBundleType con un valor de APPL), and some other informations (file type supported, version string, development language, ...). Those file is the strict minimum required to have a basic Mac OS X application.

For explanation of how the Mac OS X message pump work, I recommend the reading of this artículo by Matt Gallagher. He explains how the run message of the NSApplication class is implemented. You can then write this method runOnce that only iterate when there are pending messages. You'll then call this function periodically (it is really similar to the PeekMessage, TranslateMessage, DispatchMessage sequence on Win32):

- (void)runOnce
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    [self finishLaunching];

    for (;;)
        [pool release];
        pool = [[NSAutoreleasePool alloc] init];

        NSEvent *event =

        if (sender == nil)

        [self sendEvent:event];
        [self updateWindows];

    [pool release];

Respondido el 09 de enero de 11 a las 02:01

I don't have access to the computer that has the script to build Mac OS X bundle from .ini file but I'll try to post it monday if you think to might interest you. - Sylvain Defresne

Sounds swell! Thanks a bunch! - Jonas Byström

Unless you really want to learn a bunch of Mac-specific APIs and XCode, you should just use SDL. It's a cross-platform library that abstracts things like event handling, threading, and multimedia. It includes XCode templates that allow you to build a proper app bundle with minimal changes to your code. Using SDL would mean throwing away most of the Mac-specific code you've written, but it would vastly simplify any future ports and would make it easier to maintain your app for multiple platforms.

Respondido el 09 de enero de 11 a las 02:01

Thanks, but I prefer to do it myself and I also want to learn. - Jonas Byström

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.