Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Building Cocoa applications by hand

Building Cocoa applications by hand
Thread Tools
Samad
Fresh-Faced Recruit
Join Date: Nov 2001
Location: home
Status: Offline
Reply With Quote
Jun 16, 2004, 01:25 AM
 
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
     
calumr
Forum Regular
Join Date: Sep 2000
Location: UK
Status: Offline
Reply With Quote
Jun 16, 2004, 07:42 AM
 
"xcodebuild" from the Terminal.

There's a man page, too.
     
Angus_D
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jun 16, 2004, 04:02 PM
 
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.
     
Samad  (op)
Fresh-Faced Recruit
Join Date: Nov 2001
Location: home
Status: Offline
Reply With Quote
Jun 17, 2004, 01:55 AM
 
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.
     
Samad  (op)
Fresh-Faced Recruit
Join Date: Nov 2001
Location: home
Status: Offline
Reply With Quote
Jun 18, 2004, 01:13 PM
 
Here's a great page if anyone wants some information on precompiled headers.

http://gcc.gnu.org/onlinedocs/gcc/Pr...d-Headers.html

If anyone wants me to rewrite the sample script I wrote above to use the precompiled headers feature, I'll be glad to post it.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 02:25 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,