How to turn unix executables into .app?

Member
Posts: 90
Joined: 2006.11
Post: #1
How to turn unix executables(read: cross-platform c source) into .app?
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 90
Joined: 2006.11
Post: #3
Thanks.

(Before this I managed to get it to work by copying Audacity, going into the Audacity unix executable and replacing it with my exec and changing its name. I didn't think it was a proper way. EDIT: I only needed to replace instances of "Audacity" in info.plist with my app's name.)
Quote this message in a reply
Member
Posts: 90
Joined: 2006.11
Post: #4
I followed Apple's documentation but couldn't get my app to recognise resources in the Resource directory of the bundle; instead the resources are only recognised when placed outside the bundle. Currently it defeats the idea of having a bundle at all. Is there something I need to do? Apple's doc is all xcode xcode xcode :/
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #5
What does it mean for your resources not to be "recognized"? If you mean that trying to fopen them with relative paths doesn't work, you'll need to use NSBundle or CFBundle to get the resource path. The working directory on Mac OS X is usually neither the application's Resources directory nor the directory containing the application bundle itself, so you'll have to chdir to an absolute location first.
Quote this message in a reply
Member
Posts: 90
Joined: 2006.11
Post: #6
ThemsAllTook Wrote:What does it mean for your resources not to be "recognized"? If you mean that trying to fopen them with relative paths doesn't work, you'll need to use NSBundle or CFBundle to get the resource path. The working directory on Mac OS X is usually neither the application's Resources directory nor the directory containing the application bundle itself, so you'll have to chdir to an absolute location first.

:S I need Obj-C? That's not going to be easy.... I know how to edit and add to existing Obj-C code from... say a template project in XCode and make a decent Cocoa app... but from scratch I have no idea where to start.... not even what google keywords to put in. (Apple docs don't help non-obj-c people very much....)

Would I do what SDLMain.h in SDL.framework does, and simply include the files in our source to compile together? eg. header
Code:
#import <Cocoa/Cocoa.h>
#import "SDL/SDL.h"

@interface SDLMain : NSObject
@end
And then type some code relating to the class in the .m file?
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #7
You can do it without Objective-C by using CFBundle, which is a C API:

Code:
#include <limits.h>
#include <unistd.h>
#include <CoreFoundation/CoreFoundation.h>

...

char resourcePath[PATH_MAX];
CFBundleRef mainBundle;
CFURLRef resourcesDirectoryURL;

mainBundle = CFBundleGetMainBundle();
resourcesDirectoryURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
CFURLGetFileSystemRepresentation(resourcesDirectoryURL, true, (UInt8 *) resourcePath, PATH_MAX);
CFRelease(resourcesDirectoryURL);
chdir(resourcePath);

If this is cross-platform code, you can wrap the relevant sections in #ifdef __APPLE__ ... #endif.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Member
Posts: 90
Joined: 2006.11
Post: #9
Thanks heaps!!!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Converting unix SDL project to xcode Dominus 0 4,253 Jan 3, 2011 04:46 AM
Last Post: Dominus
  Turn Based Game API Released skilesare 0 3,968 Dec 11, 2008 06:18 PM
Last Post: skilesare
  Stupid UNIX/svn question stevejohnson 5 4,242 Dec 1, 2008 02:34 AM
Last Post: leRiCl
  Stupid xcode question: How do I turn off precompiled headers? SourceIT 2 7,437 Aug 30, 2008 12:53 PM
Last Post: SourceIT
  BSD Unix to Mac OS X Carlos Camacho 5 3,284 Jan 13, 2004 09:08 AM
Last Post: Steven