|
|
Building Cocoa applications by hand
|
|
|
|
Fresh-Faced Recruit
Join Date: Nov 2001
Location: home
Status:
Offline
|
|
I'm wondering how to build a Cocoa application by entering commands into a shell or with a makefile. When I build a project with Xcode, the Build Results window shows an incomplete list of commands Xcode executes when an application is built.
Samad
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Sep 2000
Location: UK
Status:
Offline
|
|
"xcodebuild" from the Terminal.
There's a man page, too.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
You might find the pbx jamfiles useful (/Developer/Makefiles/pbx_jamfiles). They define all the rules that Project Builder used for building applications and stuff. Moving forwards, Jam targets are deprecated and Xcode uses its own internal build system, but the jamfiles are still relevant.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Nov 2001
Location: home
Status:
Offline
|
|
Alright, I got the general format down, if anyone's curious. I haven't figured out precompiled headers yet, so this doesn't include that.
_AppName = name of application
_AppPath = location of directory where you want to store the finished application
_InfoPlist = location of your Info.plist file, usually located the $_AppName.build directory in the project directoy
_PkgInfo = location of PkgInfo file. This file is generated from Info.plist file. It is located in the same directory as Info.plist.
### Create Contents directory
mkdir -p $_AppPath/Contents
### Copy Info.plist and PkgInfo files
cp _InfoPlist $_AppPath/Contents/Info.plist
cp _PkgInfo $_AppPath/Contents/PkgInfo
### Copy resources into Resources directory
mkdir -p $_AppPath/Contentes/Resources
#copy all of your .nib files and other resources into the Resources directory
cp -r MainMenu.nib $_AppPath/Contents/Resources
### Compile source files
gcc -c -I./ -arch ppc -fno-common -fpascal-strings -Wall -Wno-four-char-constants main.m -o main.o
### Link object files, and we're done
mkdir -p $_AppPath/Contents/MacOS
gcc -o $_AppPath/Contents/MacOS/$_AppName -arch ppc -prebind -Wl,no_arch_warnings -framework Cocoa main.o
As you can see, building a Cocoa application is a very simple process. Just copy your Info.plist and PkgInfo files in the right place, then compile. Make sure to pass the "-framework Cocoa" argument when linking your application. Although getting started with one is a bit tidious, using a makefile instead of Xcode/Project Builder has its benefits. You won't have to deal with a buggy, restricting, and incredibly slow IDE. However, you may still need PB to create your Info.plist and PkgInfo files for you. And of course, you will need Interface Builder to make your .nib files.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Nov 2001
Location: home
Status:
Offline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|