Panther for developers

Unix application to Mac OS X. You can download the PDF version from the ... libc is sync'ed with FreeBSD 5.0: www. ... A huge problem raised by this upgrade ... If you use C++ code or libraries, please read carefully the GCC3 release notes: ...... InterfaceBuilder is primarily Apple's application to design graphical user inter-.
5MB taille 14 téléchargements 400 vues
Mac OS X – version 10.3 Panther for developers

Pejvan BEIGUI

Pejvan BEIGUI [email protected] www.projectomega.org v1.0.4 — 31st December 2003

Welcome Welcome to Mac OS X v10.3: Panther for developers. This guide tries to summarize and gather in one single document everything you should know in order to get started with Mac OS X v10.3. It will help you discover all the new features, applications and APIs added to Panther. Once you have had this overview, you should be ready to pick the best technologies (those which suit the best your needs, in fact) and get more in-depth help and documentation through Apple’s Developer Site (developer.apple.com) and Xcode. How to get the most of this book The best thing to do is probably to install your own copies of Panther and Xcode, and try out everything for yourself. Requirements This book assumes that you’re not a total newbie and that you are familiar with the basics of development concepts, technics, languages and tools. This includes knowing the basics of C or any other procedural language, the concepts behind Object Oriented languages and know a little bit of one of them – should it be Java, C++, Objective-C (or whatever OO language you want, although the OO APIs of Mac OS X are mostly Objective-C and Java for Cocoa and C ++ for I/OKit.) You may also be familiar with at least one IDE (Integrated Development Environment). Those available on Mac OS X v10.2 (Apple’s ProjectBuilder and Metrowerks CodeWarrior) will remain the two major IDE for Panther, also ProjectBuilder has had a major update and has evolved into a totally new breed called Xcode. We will use Xcode in this book, and haven’t had the opportunity to beta-test releases of CodeWarrior 9. We hope we’ll have a chance to include some topics about it in a forthcoming update of the document. One other thing we’ll focus on, is the Unix foundations of Mac OS X. The reason for this is pretty simple: we have seen a lot of talented Mac OS 9 developers totally ignore the Unix part of Mac OS X. Although the book does not and will not include a course about Unix, we think that every Mac OS X developer should know about Unix. Not only because it will make his life a lot easier and bring him numerous useful tools but also because he can incorporate some highly tested and stable sources in his own projects and take advantage of the millions of lines of code available for free under various licenses. That’s why we’ll assume you know the basics of Unix. (Some links to important starter guides to Unix are also provided in section 1.1.2 in case they may prove themselves useful).

About this book This book has been written and formatted with the LATEX environment. The LATEX project uses the following packages : hyperref geometry color graphicx titlesec fancyhdr alltt fancybox makeidx picins It has been generated with pdflatex. All these tools are available for free as part of the TeTEX package (www.tug.org/teTeX/). TeTEX is available through the following software/package managers: Fink (fink.sourceforge.net) DarwinPorts (opendarwin.org/projects/darwinports)

The following free and Mac OS X only environments have been used: TEXShop (www.uoregon.edu/~koch/texshop/texshop.html) iTEXMac (itexmac.sourceforge.net)

Please note that on you can click on URLs of the PDF version of this book to open the associated web pages in your default browser with PDF readers which support it (Adobe Acrobat Reader 5 and Adobe Reader 6 on most systems) and you can click on the references of many items like the number following each entry in the table of contents or in the index to get to the corresponding page and use the bookmark bar to navigate through the document if your PDF reader support it (Adobe Acrobat Reader 5 and Adobe Reader 6 on most systems and Preview on Mac OS X 10.3). About the author This book has been written by Pejvan BEIGUI ([email protected]). If you find it useful or if you have comments, fixes, bugs or improvements to suggest, please drop him an email. Copyright This book is available at no cost as a single PDF file. You can freely print it, give it away to your friends, colleagues and family. All its material is copyrighted and you should not resell, extract, translate it (should it be a small part or the whole book) without my prior authorization. If you think it is worth being published – and you have the ability to do so – please contact me ([email protected]). Please do not mirror or distribute it on your web site, link to the official web site instead: www.projectomega.org/panther-book/

Acknowledgment Thanks to all the people who helped making Mac OS X what it has become in such a short time and to those who continue to improve it and make better everyday. Thanks to Mactov for his careful proofreading. Special thanks to the Apple Developer Relations team based in Europe.

Contents 1 A Unix Called Mac OS X 1.1 Warming Up . . . . . . . . . . . . . . . . . . . . . . . . 1.1.1 Why you should know about Unix . . . . . . . . 1.1.2 Learning about Unix and the command line tools 1.1.3 Advanced Unix Users . . . . . . . . . . . . . . . 1.2 Low level updates . . . . . . . . . . . . . . . . . . . . . 1.2.1 The Mach micro-kernel update . . . . . . . . . . 1.3 Compiler update : GCC 3.3 . . . . . . . . . . . . . . . . 1.3.1 Precompiled Headers . . . . . . . . . . . . . . . 1.4 Obtaining useful software . . . . . . . . . . . . . . . . . 1.4.1 Compiling open source software . . . . . . . . . 1.4.2 Tricks . . . . . . . . . . . . . . . . . . . . . . . 1.4.3 DarwinPorts . . . . . . . . . . . . . . . . . . . . 1.4.4 Fink . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

9 9 9 9 10 10 11 11 12 13 13 14 17 20

2 The Xcode Revolutions 2.1 The Xcode CD . . . . . . . . . . . . . . . . . 2.2 The Xcode IDE . . . . . . . . . . . . . . . . 2.2.1 Elegant and flexible new user interface 2.2.2 Xcode’s Editor . . . . . . . . . . . . . 2.2.3 Code Sense . . . . . . . . . . . . . . 2.2.4 Documentation Browser . . . . . . . . 2.2.5 Predictive compilation . . . . . . . . . 2.2.6 Parallel Builds . . . . . . . . . . . . . 2.2.7 Distributed Builds . . . . . . . . . . . 2.2.8 Zero Link . . . . . . . . . . . . . . . 2.2.9 The Inspector . . . . . . . . . . . . . 2.2.10 Fix and Continue . . . . . . . . . . . 2.2.11 Debugger Data Formatters . . . . . . 2.2.12 Performance Tools Integration . . . . 2.2.13 CVS and Perforce Integration . . . . . 2.2.14 SDK Support . . . . . . . . . . . . . 2.2.15 Scripting Xcode . . . . . . . . . . . . 2.2.16 Native Targets . . . . . . . . . . . . . 2.3 InterfaceBuilder 2.4 . . . . . . . . . . . . . . 2.3.1 Updates for both Carbon and Cocoa . 2.3.2 Updates for Cocoa . . . . . . . . . . 2.4 Updates for Carbon . . . . . . . . . . . . . . 2.5 Command Line developer tools . . . . . . . . 2.6 Performance and Profiling Tools . . . . . . . 2.6.1 The Performance Tools . . . . . . . . 2.6.2 The CHUD Tools . . . . . . . . . . . 2.6.3 the CHUD framework . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

25 25 26 26 27 27 28 29 30 31 33 33 33 34 36 36 37 38 40 41 41 41 48 48 57 58 61 67

3 Major New APIs 3.1 The Web Kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

69 69

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . .

3.2

3.3

3.1.1 Historical facts . . . . . . . . . . . . . . . . . . . . . 3.1.2 Introducing the Web Kit . . . . . . . . . . . . . . . 3.1.3 URL Loading API . . . . . . . . . . . . . . . . . . . 3.1.4 Web Kit . . . . . . . . . . . . . . . . . . . . . . . . The Search Kit . . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 Introducing Search Kit . . . . . . . . . . . . . . . . 3.2.2 Principles of indexing . . . . . . . . . . . . . . . . . The Address Book Framework . . . . . . . . . . . . . . . . 3.3.1 The Address Book Framework . . . . . . . . . . . . 3.3.2 AppleScript Support in the Address Book application 3.3.3 More developer perspectives . . . . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

69 70 71 71 73 73 74 75 75 76 76

A Categorized CLI developer tools

79

B Networking APIs in Mac OS X 10.3

81

List of Figures 1.1 1.2

The Ports Manager application. . . . . . . . . . . . . . . . . . . . . . . . . . . . The FinkCommander application. . . . . . . . . . . . . . . . . . . . . . . . . . .

19 22

2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 2.12 2.13 2.14 2.15 2.16 2.17 2.18 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31

Install the XCode Tools. . . . . . . . . . . . . . . . . . . . . . The default project window. . . . . . . . . . . . . . . . . . . . SmartGroups make the window more readable. . . . . . . . . . Command-double-clicking in the editor links you to the editor. Customize and/or learn about the available shortcuts. . . . . . Configure Code Sense so it behaves the way you want it to. . Code Sense auto-completion in action. . . . . . . . . . . . . . The Xcode documentation browser. . . . . . . . . . . . . . . the Distributed Builds configuration panel. . . . . . . . . . . . the Inspector gives access to virtually any setting. . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

26 27 28 28 29 30 30 31 32 34 35 36 37 38 39 40 42 42 43 43 44 45 46 47 49 59 59 61 62 64 67

3.1 3.2

The global network technology layers . . . . . . . . . . . . . . . . . . . . . . . . . Configuring the People Picker with the Inspector of InterfaceBuilder . . . . . . . . . .

72 77

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

The debugger’s new UI sports two different layouts – available from the Debug Quickly launch your project using one of the performance tools . . . . . . . . The SCM pane of the Inspector . . . . . . . . . . . . . . . . . . . . . . . Use the project’s Inspector to set up the deployment target. . . . . . . . . . Execution of the ls -lh /Developer in Xcode . . . . . . . . . . . . . . . The sample Scripts menu of XCode . . . . . . . . . . . . . . . . . . . . . The new Nib tab help you fix incompatibilities . . . . . . . . . . . . . . . . The Incompatibility window gives you important details . . . . . . . . . . . Size does matter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Notice the new widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . Notice the new widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . The incredible AddressBook Palette . . . . . . . . . . . . . . . . . . . . . Create your own browser with WebKit embedded . . . . . . . . . . . . . . . The new binding feature is unbelievably powerful . . . . . . . . . . . . . . . The best web browser on the planet? . . . . . . . . . . . . . . . . . . . . MallocDebug helps you find bugs and improve your code . . . . . . . . . . . ObjectAlloc shows memory (de-)allocations in real time . . . . . . . . . . . SpinControl helps you improve the user experience of your product . . . . . . BigTop is the graphical equivalent of the top CLI tool . . . . . . . . . . . . Shark tries to help you improve your product’s performance with its advices . Hardware lets you disable memory caches or processors on-the-fly . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

. . . . . . . . . .

menu.

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . .

8

Project:Ω — Panther for Developers

Chapter 1

A Unix Called Mac OS X This first chapter is dedicated to Mac OS X as a Unix – or, more precisely, to Darwin. Users who don’t know anything about Unices will find some useful links to get started with before reading further. The other users, those who know about the concepts behind Unix and who are not afraid of the command line and the Terminal will find useful information, tips, tricks which will hopefully make their life easier.

Warming Up Why you should know about Unix Mac OS X is a Unix. It’s a fact and hopefully, this won’t change for a while. If you really want to understand Mac OS X, administrate it to fit your needs and find and fix quickly the issues you are facing, you would better know about Unix and its command line tools. You must for example know about the security aspects of Unix, like the file permissions, the different users, the user and group ids (uid and gid). This can save you a lot of trouble. What about POSIX? This very powerful and universal set of functions can deliver its true power only to the people who know what they are dealing with. Thanks to the command line tools, you can automate a lot of things inside Mac OS X, write shell scripts and make your life a lot easier. You can also fix a lot of issues that you can’t fix with the graphical user interface (GUI). You can for example kill and relaunch processes. How many people (even among developers) have I seen restart their computer because of a process which needed to be killed and relaunched? Explaining all the benefits of learning Unix would take dozens of pages but please take the time to learn the basics: it’s definitely worth it. We will help you with this task, in the next sections.

Learning about Unix and the command line tools Before going any further, please make sure you are comfortable enough with the basic knowledge about Unix and command line tools (referred also as CLI tools for Command Line Interface tools). Teaching about Unix, the Terminal app and the CLI tools is beyond the scope of this document. You can find valuable information and tutorials on O’Reilly’s MacDevCenter (www. macdevcenter.com/pub/a/mac/collections/unix.html) and on Apple’s web site dedicated to Unix development (developer.apple.com/unix)

Please Note We now consider that you are comfortable enough with the Terminal to pratice and understand the basic commands found in this book. We will also assume that you have installed Apple’s Developer Tools for Panther.

Advanced Unix Users If you’re an advanced Unix user new on Mac OS X, Apple’s Mac OS X for Unix Users technology brief is made for you. You can download this 10-page document specifically focused on Unix from the following URL: http://www.apple.com/macosx/pdf/Panther_Unix_TB_10082003.pdf. You may also be interested in Apple’s UNIX Porting Guide which will help you bring your Unix application to Mac OS X. You can download the PDF version from the following URL: developer.apple.com/documentation/Porting/Conceptual/PortingUnix/PortingUNIXToOSX. pdf.

Useful URLs www.macdevcenter.com/pub/a/mac/collections/unix.html developer.apple.com/unix www.apple.com/macosx/pdfs/MacOSX_for_UNIX_users_TB.pdf developer.apple.com/documentation/Porting/Conceptual/PortingUnix/

Low level updates NB: As of the writing of this book, very few information is available regarding the changes in Darwin. This document will be updated as soon as more information is made available. Here’s a pell-mell of the updates in the lower layers of Mac OS X: · · · · · · · · · · · · · · · ·

Darwin is now versionned 7.0: opensource.apple.com/darwin libc is sync’ed with FreeBSD 5.0: www.FreeBSD.org GCC is updated to version 3.3: gcc.gnu.org/gcc-3.3/changes.html libXML 2 2.0: www.xmlsoft.org perl 5.8.1: dev.perl.org/perl5 python 2.2.3: python.org/2.2.3 tcl 8.4.1: www.scriptics.com/software/tcltk/8.4.html ruby 1.6.8: www.ruby-lang.org/en Samba 3.0: samba.org/samba/whatsnew/samba-3.0.0rc1.html BIND 9: www.isc.org/products/BIND Kerberos 5: web.mit.edu/macdev/www/kerberos.html PHP 4 (v4.3.2): www.php.net UFS: has almost the same performance as HFS+ now. Journalized HFS+: Journaling is now turned on by default SMB, NFS, WebDAV filesystems: Performance improvements CUPS 1.1.19: major fixes, fax support, better PPD parsing, security updates

10

Project:Ω — Panther for Developers

· Gimp-Print is now integrated to Mac OS X: drivers for unsupported Canon, Epson, Lexmark, and PCL printers

· · · ·

Apple X11 1.0: Bundled with Mac OS X, based on XFree86 4.3 and native OpenGL Ant, XDoclet, JBoss 3.2.2: J2EE development now provided by the developer tools Major network updates: Such as Rendezvous, IPv6, IPSec, VPN, 802.1x Highly anticipated functions and updates: Such as International Components for Unicode (ICU), wchar t, net-snmp, NFS locking, vim, postfix, tar, more, etc.

Basically, it seems that every component of the OS has been updated. More info is given about the components later in the upcoming sections and chapters, when relevant. Please also note that we haven’t even mentioned any API yet!

The Mach micro-kernel update No information available yet.

Compiler update : GCC 3.3 Since the very first release, Mac OS X has been compiled with gcc. As you probably already know, Mac OS X 10.2 was compiled with gcc 3.1, which provided a big step forward in the quality of the generated binary code. This was one of the reasons why Mac OS X 10.2 was so much faster (the other reason being the very hard work made by Apple in optimizing every area of its OS). But, one did not get these optimizations for free. A huge problem raised by this upgrade caused by major changes in the application binary interface (ABI) of the C++ back-end of the compiler. We’ll go into more details before the end of this section. Changes in the ABI should be quite exceptional and almost never occur. Unfortunately, with gcc 3.2 the ABI changed one more time which makes it twice in a year (hopefully, the last time for a very long period). Mac OS X 10.3 is built with gcc 3.3, which has the same C++ ABI as gcc 3.2 and hence all the issues raised by the update from gcc 2.x to gcc 3.1 have occured one more time. Fortunately, the upgrade to 3.3 also brings a lot of nice and useful features. GCC 3.3 is now the default compiler for C, C++, Objective-C, Objective-C++ and can be used for any new project. Switching to gcc 3.3 should be pretty painless as far as you don’t use C++ or link against C++ libraries. But, because of the changes in the C++ ABI, you must link your C++ sources against libraries which have been compiled by the same version of the compiler. That is to say that you want to use a binary library or if you want to provide a binary library, you must be very careful and check the version of the compiler you have to use. You may have to recompile your code if its not self contained. As far as only the C++ ABI is concerned, you do not need to recompile C and Objective-C code.

Please Note If you use C++ code or libraries, please read carefully the GCC3 release notes: file:///Developer/Documentation/ReleaseNotes/DeveloperTools/GCC3.html

Now the good news: gcc 3.3 is more compliant to the C99 and C++ standards. It is also significantly faster to compile compared to gcc 3.1. It supports a new form of precompiled headers Chapter 1 : Compiler update : GCC 3.3

11

(PCH) which replaces the previous precompiled headers of gcc 3.1. It also supports ObjectiveC/Objective-C++ exception and synchronization and CodeWarrior style inline assembly.

Precompiled Headers In the current development process, almost any file of a given project includes the same header files. This is always the case when you build GUI applications: should it be PowerPlant, Qt, Cocoa’s AppKit, you have to include all the headers of these frameworks. Compiling these header files can take a considerable amount of time. Even worse: compiling this framework sometime represents a large part of the whole compile time (like 90 to 95% for the smallest projects). That’s the reason why GCC allows you to create a header file which will be ’precompiled’ and will greatly improve the compilation time of source files which use it. In order to use the precompiled header file, you have to put it in the same directory as the corresponding header (of course, the header must be included with the #include statement). Precompiled headers must have the .gch suffix appended to the name of the header file. For example, the precompiled header corresponding to the myFramework.h header will be myFramework.h.gch. The main difference between the new precompiled headers system used in Mac OS X 10.3 and the one used in Mac OS X 10.2 is that you can now have precompiled headers for C++. Before creating and using your own precompiled headers, it is important to know the rules and restrictions which apply. It’s recommended that you read the GCC man page about Precompiled Headers if you’re planning to deal with them manually. Fortunately, your IDE (such as Xcode, for example) should take care of this task without you having to do anything but taking advantage of the speed boost.

Useful URLs For more information about Precompiled Headers, please read: file:///Developer/Documentation/DeveloperTools/Conceptual/ ¬ MovingProjectsToXcode/migration differences/chapter 2 section 25.html

 Wrapping up GCC 3.3 features: · greatly improved optimization, specially for Altivec code · significantly faster compile times · support for 64-bit processors (PowerPC 970 aka G5) · precompiled headers, inline assembly, Obj-C/Obj-C++ exception/synchronization · major bug fixes

12

Project:Ω — Panther for Developers

Optimization flags in GCC 3.3 I -O0 must be used for debug builds -O performs simple optimizations -O2 performs all of GCC’s optimizations that don’t involve a space-time trade-off -O3 performs more optimization I -Os is recommended by Apple for deployment and produces the smallest binary size. Its performance is similar to -O2. -faltivec optimizes code for Altivec -mtune allows you to optimize the binary for a specified processor -ffast-math optimizes some mathematical functions -falign-loops, -falign-functions and -falign-jumps perform code alignments Find more information and more flags in the optimization section of the releases notes: file:///Developer/Documentation/ReleaseNotes/DeveloperTools/GCC3.html

For further details about gcc and the other compilation tools, please refer to the section 2.2 (page 26).

Obtaining useful software This section deals with several of the very important and interesting features of Mac OS X seen as a Unix. We will show you how to compile the sources you may find on the Internet, how to deal with different variants of the compile system and finally how to make this whole process – fetching, patching, compiling and installing open source software – seamless. You will be amazed to see that it can be as easy as typing a short command line in the Terminal or clicking on a few buttons.

Compiling open source software As a Unix and Open Source software user, you’re probably familiar with the GNU autotools and the very straightforward compilation experience they provide.

Crash Course: autotools · · · ·

autconf: system for generating configure script configure: script used to check the availability of required libs on your system automake: tool used for generating GNU Makefiles autobook: book about autotools – published under the Open Publication Licence

So let’s have a quick example of the way they are used. We will now fetch the sources from a project called links, we will compile them and run the resulting tool. Chapter 1 : Obtaining useful software

13

Terminal Session: building links mkdir ~/sources cd ~/sources/ curl -O http://links.sourceforge.net/download/links-0.99pre6.tar.gz tar xzf links-0.99pre6.tar.gz cd links-0.99pre6 # Here begins the actual process: ./configure make # If you want to give a try to links before installing it: ./links http://links.sf.net sudo make install

Please Note The # symbol used here doesn’t mean that you have to try and type it. Consider the lines beginning with a # as comments you can read to get more info about what’s going to happen next.

As you can see, you only have to trigger three simple commands to get the sources compiled and installed. We compiled a fairly simple project here: it has no real dependencies and generates only one binary file. That’s why we could have skipped the install line for example. If the project has a lot of dependencies and/or if you have tweaked your system to fit your needs, you have installed libraries or headers in other places. You can tell the configure script about these locations. You can also tell it where you want to install the files. For more information about these settings, please run the configure script passing it the --help argument. Terminal Session: configure help ./configure --help

Tricks We’ll try to briefly discuss the issues you may encounter while trying to compile sources and we’ll give you some tricks which will fortunately solve these issues. configure issues The first issue you may encounter is a configure script which fails because the required libraries and/or headers are not available on your system. You can find out what these missing headers and libraries are, fetch them and compile them. But then what happens if you want to build a project which depends on dozens of libraries, including Gtk or GNOME? make issues You should know that there are two different make tools, one of them is bsdmake and is provided by FreeBSD while the other is gnumake and is provided as part of the GNU project. Some very rare project may depend on one of these and not build with the other. The default make on Mac OS X is the GNU one, so if you fail to build because of the make tool, 14

Project:Ω — Panther for Developers

try reading the documentation which came with the sources and run bsdmake instead of make. Terminal Session: about make % ls -l /usr/bin/ | grep make [. . . ]

-r-xr-xr-x 1 root wheel

119676 17 Aug 20:30 bsdmake

[. . . ]

-rwxr-xr-x 1 root wheel lrwxr-xr-x 1 root wheel

144152 17 Aug 16:13 gnumake 7 24 Aug 23:10 make -> gnumake

[. . . ]

Please Note The % symbol used in the first line doesn’t mean that you have to try and type it. Since we have displayed here the output of the command, we have prefixed it with a % symbol to make sure the input and the output are distinct enough.

gcc issues We have already mentioned some issues which may be resulting from the gcc update in the section 1.3 (page 11). You should also know that some projects are more tied to a gcc version than they should since they won’t build because of the internal changes of gcc. You may also need to compile the project with gcc 3.1 or 2.95 because of C++ libraries or the deployment platform you use. If this is the case, consider installing the different versions of gcc from the Xcode CD before reading any further. Terminal Session: gcc community % ls -l /usr/bin/ | grep cc lrwxr-xr-x 1 root wheel

7 24 Aug 23:10 cc -> gcc-3.3

[. . . ]

lrwxr-xr-x 1 root wheel -r-xr-xr-x 1 root wheel -r-xr-xr-x 1 root wheel

7 24 Aug 23:10 gcc -> gcc-3.3 131720 18 Aug 11:50 gcc-3.3 135828 18 Aug 11:49 gcc3

Fortunately, Apple has provided a very neat tool to help you solve your issues. This tool is gcc select and it allows you to select any available version of gcc as the default one for your system. You can see in the previous ”Terminal Session” that several versions of gcc are installed on the host and that Apple has had the good idea to provide symbolic links to the default gcc for cc (which may prove itself useful when trying to compile some old sources for example). gcc3 is in fact gcc 3.1 while gcc-3.3 is gcc 3.3 and if you had installed gcc 2.9.5, it would have been named gcc2.

Chapter 1 : Obtaining useful software

15

Terminal Session: gcc select % gcc -v Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs Thread model: posix gcc version 3.3 20030304 (Apple Computer, Inc. build 1492) % gcc select -l Available compiler versions: 2.95.2 3.1

3.3

3.3-fast

% sudo gcc select 3.1 Password: Default compiler has been set to: Apple Computer, Inc. GCC version 1256, based on gcc version ¬ 3.1 20021003 (prerelease) % gcc --version gcc (GCC) 3.1 20021003 (prerelease) Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Please Note · gcc -v and gcc --version don’t have the same outputs. · don’t be fooled by the output of gcc select -l: we haven’t installed gcc 2.95.2 since the previous ”Terminal Session”. · for more info about gcc select, run gcc select -h or read the release notes: file:///Developer/Documentation/ReleaseNotes/DeveloperTools/GCC3.html

 Wrapping up Mac OS X provides everything you need to compile Unix and Open Source software. It can be very easy to do so but it can also be pretty tricky. Fortunately you can find valuable help in Apple’s UNIX Porting Guide and in the two powerful tools unveiled in the following sections.

16

Project:Ω — Panther for Developers

DarwinPorts

One of the Unix-centric feature of Mac OS X 10.3 is the ability to install the DarwinPorts tools. DarwinPorts is a tool which is very similar to the FreeBSD ports collection or – as we will see in the next section – Fink. It takes in charge the whole process – finding dependencies, fetching the sources over the Internet, building and installing – for any given supported piece of software. Something very important to know is that we’re not talking about 4 or 5 different packages here but about hundreds! To learn more about DarwinPorts, please take a look at the following document: darwinports. gene-hacker.net/docs/guide/ch01s02.html Unfortunately, the DarwinPorts tool which was installed by the prerelease version of Panther was quite old and didn’t work very well. Is this an issue? No, since it’s an opensource project, you can pull the latest version of the sources from the CVS server and build them on your computer. That’s what we are going to do now. Hence, you’ll see how you can check out sources from CVS and update your software and maybe learn a few tricks during this process.

Terminal Session: building DarwinPorts #we have created the ’sources’ during the previous terminal session cd ~/sources #press Return when prompted for the CVS password cvs -d :pserver:[email protected]:/Volumes/src/cvs/od login #checking out the port tool sources cvs -d :pserver:[email protected]:/Volumes/src/cvs/od co ¬ -P darwinports #checking out the PortsManager Cocoa application sources cvs -d :pserver:[email protected]:/Volumes/src/cvs/od co ¬ -P PortsManager #building and installing the port tool cd darwinports make sudo make install #storing the ports repository in a nice and convenient place cd .. ; mv darwinports /Users/Shared #building the PortsManager GUI application cd ~/sources/PortsManager/ xcodebuild -project PortsManager.pbproj -activetarget -buildstyle Deployment #replacing the old PortsManager application by the new one cp -r "build/Ports Manager.app" /Applications/Utilities/ #launch your new PortsManager application from the command line open /Applications/Utilities/Ports Manager.app

Chapter 1 : Obtaining useful software

17

Please Note The ¬ symbol used here doesn’t mean that you have to try and type it. Because of the page width constraints, we have had to break one single line of code into several. Hence, you should type one single line ignoring the ¬ character.

By default, all the files have been installed in the following repertories: /opt/local/bin/ contains the command line building utility named port /opt/local/share/darwinports contains TCL libraries used by the ports system /opt/local/ is a new separate file system you’ll have to take into account. Before you can install and use any of these new tools, you have to go through some configuration. We will enable the local ports repository and then set the path to the appropriate bin man and lib repertories used by port. In order to do this, you have to first edit the /etc/ports/sources.conf file and then your various paths in your .tcshrc file. Here is how they can look like, if you have followed the previous Terminal Session:

% cat /etc/ports/sources.conf # To enable your local ports repository, uncomment and customize # the following line to point at your local dports directory # Example: file:///Users/landonf/misc/darwinports/dports # file:///usr/dports file:///Users/Shared/darwinports/dports % cat ~/.tcshrc setenv PATH {$PATH}:/usr/local/bin:/opt/local/bin setenv MANPATH {$MANPATH}:/opt/local/man # note: if you haven’t set a MANPATH yet, use the following # command instead of the previous one: # setenv MANPATH /opt/local/man

Please Note In Mac OS X 10.3 the default shell has been switched from tcsh to bash. If you are using the default bash shell, please add the following commands in the ~/.bash profile file (instead of editing the .tcshrc file): PATH=$PATH:/usr/local/bin:/opt/local/bin MANPATH=/opt/local/man If your default shell is not the tcsh or if you have changed the default location of the install or modified your path, change your environment to reflect the changes we made in the .tcshrc file or switch to tcsh as the default shell. We will consider tcsh as the default shell for the rest of this book.

Please take the time to do the tuning you need. In the previous example, for example, we didn’t add the sbin repertory to the PATH. Unix is flexible, make it behave the way you want it to. 18

Project:Ω — Panther for Developers

Crash Course: port CLI tool Here are the most common and useful port commands: · port list: lists all the available ports · port search wget: searches all the ports containing the string ’wget’ · port install wget: installs the port ’wget’ · port uninstall wget: un-installs the port ’wget’ · man port: the man page for the port CLI utility

You can now finally launch the Port Manager application, if you don’t want to deal with the Terminal for installing third party Unix software. You can see on figure 1.1 a screenshot of the application. You can browse among the different different categories and packages and see for example that on the October 30th 2003, 604 ports were available through DarwinPorts. Take the time to play with both the CLI utility and GUI application. We also suggest that you install the tool wget which you find in the net category because we’ll use it in the next section.

Figure 1.1: The Ports Manager application.

Chapter 1 : Obtaining useful software

19

Useful URLs · Official web site: www.opendarwin.org/projects/darwinports · Available packages: www.opendarwin.org/projects/darwinports/en/ports.php · A guide to DarwinPorts: darwinports.gene-hacker.net/docs/guide

Fink Conceptually, the Fink and DarwinPorts project share the same goal – bring Open Source software to Mac OS X – with the notable difference that Fink has been around for a couple more years, is widely spread and the community around it is really huge. While DarwinPorts is similar to the BSD ports like FreeBSD ports, Fink is based on the GNU/Linux Debian tools (like dpkg , apt-get, dselect) and provides its own package manager, a CLI utility named fink. One other difference with DarwinPorts is that you can also choose to install precompiled packages instead of compiling it from the sources. Do you remember the issues about gcc version changes we discussed in the section 1.3? Well, Fink is probably the project which will suffer the most from this. Imagine millions of lines of code, a rather important part in C++, and incompatibility issues because of both the ABI changes and the compiler behavior changes. As of the writing of this book, the developers of Fink have still to decide among the various solutions they have found. That’s the reason why all the packages available in Fink (2979 as of October 30th 2003 and already 1400 ported to gcc3.3 and Mac OS X 10.3). But Fink is still quite usable. My advice to make the transition as nice as possible when moving to Mac OS X 10.3 is to reinstall it from scratch – this is what I’ve decided to do, in order to have a nice and clean distro. Terminal Session cd ~/sources #Download the latest source version from fink.sourceforge.net (0.6.0 when writing this sectin) curl -O http://heanet.dl.sourceforge.net/sourceforge/fink/fink-0.6.0-full.tar.gz #extract the files from the archive and change to the source directory tar zxf fink-0.6.0-full.tar.gz cd fink-0.6.0-full #launch the install script, follow the instructions and answer the questions ./bootstrap.sh /sw #update the core of fink fink selfupdate-rsync

Once you are done with the configuration, add source /sw/bin/init.csh to your .tcshrc file. You also have to add the unstable branches to your Fink tree, if you want to make sure to have the latest packages which are being added to the 10.3 branch. The last thing I have done is to change the download method so it uses wget instead of curl. If you haven’t installed wget 20

Project:Ω — Panther for Developers

yet, you can install it by fink and then change the DownloadMethod. Here’s how your files may look like now: % cat ~/.tcshrc source /sw/bin/init.csh setenv PATH $PATH:/usr/local/bin:/opt/local/bin setenv MANPATH $MANPATH:/opt/local/man % cat /sw/etc/fink.conf # Fink configuration, initially created by bootstrap.pl Basepath: /sw RootMethod: sudo DownloadMethod: wget Trees: local/main stable/main stable/crypto unstable/main ¬ unstable/crypto local/bootstrap Distribution: 10.3 Mirror-cpan: ftp://ftp.lip6.fr/pub/perl/CPAN/ Mirror-ctan: ftp://ftp.tex.ac.uk/tex-archive/ Mirror-debian: http://ftp.fr.debian.org/debian/ Mirror-gimp: ftp://stef.u-picardie.fr/mirror/ftp.gimp.org/ Mirror-gnome: ftp://fr2.rpmfind.net/pub/GNOME/ Mirror-gnu: ftp://ftp.cs.univ-paris8.fr/mirrors/ftp.gnu.org/ Mirror-kde: ftp://ibiblio.org/pub/packages/desktops/kde/ Mirror-master: http://distfiles.opendarwin.org/ Mirror-rsync: rsync://master.us.finkmirrors.net/finkinfo/ Mirror-sourceforge: http://eu.dl.sourceforge.net/sourceforge/ MirrorContinent: eur MirrorCountry: eur-fr MirrorOrder: ClosestFirst ProxyPassiveFTP: true Verbose: 3 SelfUpdateMethod: rsync

Crash Course: fink CLI tool Here are the most common and useful fink commands: · fink list: lists all the available ports · fink list wget: searches all the packages containing the string ’wget’ · fink describe wget: give the detailed description of the package ’wget’ · fink install wget: installs the package ’wget’ · fink uninstall wget: un-installs the package ’wget’ · fink update wget: updates the package ’wget’ to the latest version · fink selfupdate-rsync: updates the core of fink with the new rsync method¬ added to the 0.6 version. · fink selfupdate-cvs: updates the core of fink using the cvs method. Prefer using¬ the rsync method, since the cvs is almost allways overloaded. · fink selfupdate: updates the core of fink to the latest version using ¬ the method specified in the SelfUpdateMethod field · man fink: the man page for the port CLI utility As you may see – and as end user perspective which is blind to the religious reasons to use Fink Chapter 1 : Obtaining useful software

21

or DarwinPorts – Fink seems more mature and has several great advantages over DarwinPorts – at least to the author’s point of view. For example, DarwinPorts lacks two major functions when compared to Fink: first, it cannot selfupdate so you have to update manually the dports repository and second, it cannot update a port, you have to uninstall it and then reinstall the latest version. Fink has also a lot more packages than DarwinPorts and they are up to date, which is sometimes not the case for DarwinPorts. And finally, Fink provides binary packages too, which may save you a lot of time if you have limited horsepower. Did I mention the whole community created by Fink? Anyway, we suggest that you use both of them for a while, and make your idea about each. The Fink project has also a graphical companion project called FinkCommander. FinkCommander is a GUI for the various tools of Fink – fink and apt-get, mainly – and provides almost all the functions of the CLI tools in a convenient graphical application. You can download and install it from finkcommander.sourceforge. net. Figure 1.2 provides a screenshot of FinkCommander and shows some of its functionalities. FinkCommander's main window

The Inspector window shows you the description of the package

The browser window lets you see the content of the package

Figure 1.2: The FinkCommander application.

22

Project:Ω — Panther for Developers

Useful URLs · Official web site: fink.sourceforge.net · Available packages: fink.sourceforge.net/pdb/ · FinkCommander’s official site: finkcommander.sourceforge.net

We have provided here a lot of information which will hopefully help you as a user but also as a developer. Our other goal here was to make you feel the fact that the developer has to know the best he can his operating system – and Mac OS X is a Unix – in order to leverage its power and create the best application possible. We have introduced in this chapter some command line tools we use all the time but a lot more are to be discovered. Some of them will be approached in the chapter about Xcode.

Chapter 1 : Obtaining useful software

23

24

Project:Ω — Panther for Developers

Chapter 2

The Xcode Revolutions This chapter is dedicated to Xcode, the great new IDE from Apple. Xcode provides tight integration with Mac OS X and many new features — some of which, such as fix and continue, code sense, zero-link, are quite amazing and previously unseen. The Xcode CD The Xcode CD was formerly known as the Developer Tools CD. It provides the latest versions of everything that used to be provided as the Developer Tools and even more. For example, the CHUD Tools are now part of the whole package. Xcode is also the name of the new IDE and our old friend ProjectBuilder is now left behind. Xcode will let you do everything you did with ProjectBuilder and much more: It provides everything you need to develop great applications on Mac OS X, should you use Carbon, Cocoa, Java or any other kind of development related to Unix or Mac OS X (Kernel Extensions, Frameworks, Unix CLI tools, Qt or PowerPlant apps, etc.) and has many amazing new features which will be covered in this chapter. First of all, install the software. You will notice several new packages as soon as you try to customize the installation (Figure 2.1): · Cross-Development: allows you to develop for three different versions of Mac OS X – 10.1, 10.2 and 10.3. GCC 2.95.2 will probably be needed if you want to target C++ code for Mac OS X 10.1. You can therefore use Panther and build software for Mac OS X 10.1, 10.2 and 10.3. · X11 SDK: needed to build graphical applications running in the X-Window environment. · Java Application Servers Developer Tools: installs the development version of JBoss and other useful J2EE development tools such as Ant, XDoclet. · Note that PHP 4 and Tomcat are now part of the default install of Mac OS X, and since Apache was already available, you just have to choose your database server (for example, MySQL and PostgreSQL are available through Fink and DarwinPorts) to start your web development. · CHUD Tools: installs the CHUD Tools (version 3.0.1 is the latest one available as the writing of this book). More information about the CHUD Tools are available in section 2.6.2 (p.61).

Figure 2.1: Install the XCode Tools.

The Xcode IDE ProjectBuilder used to be a simple and nice IDE. We think it was well suited for small to medium projects, but it lacked the industrial strength and features needed for bigger projects and this was probably one of the reasons why its adoption has not been very fast in large software companies. The other reason being probably that major companies such as Adobe or Macromedia use CodeWarrior for their Carbon development needs and they were quite happy with it since it provided so much more controls over the project. As we already mentionned, Xcode will fortunately fill the gap since it provides so many exclusive features and technologies. We will discuss some of them through this section.

Elegant and flexible new user interface Xcode sports a brand new user interface which is both elegant and flexible. Elegant because it’s Apple made (and it integrates perfectly with all the Mac OS X applications) and flexible because you can customize almost everything. You liked ProjectBuilder a lot? You can get its user interface back. You preferred CodeWarrior and its project window? You can get the same layout in Xcode now. The brand new interface of Xcode has been totally revamped with the iTunes point of view. Since iTunes is so perfect for managing thousands of songs and give you quick and easy access to any of them, why wouldn’t your IDE do the same and manage thousands of source files and give you quick access to any of them? This is the reason why the new default project window features a Group & Files column which should remind you the Source column of iTunes. The Search field on the top of the window and iTunes’ one share the same purpose (Figure 2.2). You use it to filter the listed elements in the 26

Project:Ω — Panther for Developers

main pane. This filtering function is very fast and the results of the filtering appear as you are typing in the field. The Groups & Files column looks like iTunes' Source column

The Search field should soon be available in almost any Mac OS X application

the 2 default SmartGroups, the equivalents of iTunes' SmartPlaylists

Figure 2.2: The default project window.

Group and SmartGroup concepts are equivalent to iTunes’ Playlists and SmartPlaylists. On the Figure 2.3, we have created a project containing the sources of Links and created two new SmartGroups, one for the C files and the other for the C++ ones (Groups and SmartGroups are created thanks to the Group menu).

Xcode’s Editor Xcode’s editor is basically the same editor as in ProjectBuilder, except that it’s now used by Code Sense, Fix & Continue. The Syntax-aware indenting is still there and helps you write readable and clean source files. We particularly appreciated the fact you can now change the line endings for existing files. Mac OS X 10.3 now allows you to edit all the keyboard shortcuts thanks to the Keyboard & Mouse pane of the System Preferences. This feature appears in Xcode too and you can now configure all the key bindings in the Preference window. This applies not only to the shortcuts for the menu items, but also for the editor. Plus, it’s a great way to learn about all the shortcuts available (Figure 2.5).

Code Sense Code Sense is Apple’s answer to the code auto-completion need. This was one of the features that badly lacked in ProjectBuilder. Hence, you can now activate Code Sense for two different features. The first one is code indexing , which allows you fast searching and filtering. The second Chapter 2 : The Xcode IDE

27

The main group may be confusing

Two new SmartGroups showing C and C++ files, respectively

SmartGroups are easy to create and very handy

Figure 2.3: SmartGroups make the window more readable.

Figure 2.4: Command-double-clicking in the editor links you to the editor.

one is code completion. And since Xcode had to be flexible, you can customize pretty much everything about Code Sense in the Navigation pane of the Xcode Preference window (Figure 2.6). Henceforth, a function menu will pop-up and show you a list of elements for you to select the item you want. But as usual, Apple couldn’t be satisfied with what other companies have done, Apple had to make a better one. That’s why you’ll find some great features such as context-sensitive code completion and class browsing (thanks to the indexing) but what is really new here, is that it works with uncompiled code whereas on others IDE, you usually need to have already build a debug version of the code. Code Sense works for C, C++ and Objective-C and Java. Figure 2.7 shows how it behaves.

Documentation Browser The brand new documentation browser of Xcode lets you search and browse the developer documentation. It is not perfect yet, but it really is a major improvement. The search field, which Apple wants to be available in as many applications as possible, allows you to search among all the different constants, functions and methods from the various frameworks of the system. You can also do full text searches from the same field. The search system uses the new SearchKit for searching and WebKit to display the HTML 28

Project:Ω — Panther for Developers

Figure 2.5: Customize and/or learn about the available shortcuts.

documentation. Hence, it is fast and efficient.

Useful URLs More information: file:///Developer/Documentation/DeveloperTools/Conceptual/XcodeQuickTour/qt_techinfo

Cocoa Browser – browser for the Cocoa reference documentation: homepage2.nifty.com/hoshi-takanori/cocoa-browser AppKiDo – browser for the Cocoa reference documentation: homepage.mac.com/aglee/downloads

Predictive compilation Predictive compilation is another new smart technic used by Apple to try to reduce the visible compile time – the other technic being the Precompiled Header (see section 1.3.1, page 12). We talk about visible compile time here because this technic doesn’t actually reduce the compile time – at least the same way that optimizing the code of GCC would do. But it rather makes you feel like the compile time is a lot faster by compiling your sources in the background, while you are working on your project. And since the major part of the compiler’s work is to deal with the framework headers and you are often only working on one or two source files at the same time, building the whole project requires to compile only these last files. So the result is that once you click on the build button, there’s about one or two percents of the whole work left to do. The other feature of the Predictive Compilation feature is to check your code while you’re editing it. Since most developers use the compiler as a syntax-checker and click on the build Chapter 2 : The Xcode IDE

29

Figure 2.6: Configure Code Sense so it behaves the way you want it to.

Code Sense auto-completes as much as possible without opening the pop-up menu. Press the Tab key to complete.

Then, the menu showing you the different completions pops up. Press the Tab key to select the highlighted one.

Code Sense has completed the function name for you. It also writes down the argument placeholder. All you have to do then is to type in the argument (of the type 'struct terminal' in this example)

Figure 2.7: Code Sense auto-completion in action.

button every few minutes, it’s a real time saving feature. To take advantage of the Predictive Compilation, you have to enable it in the Building pane of the Xcode Preferences window.

Parallel Builds The Parallel Build feature was already available in ProjectBuilder. It helps you get real faster compile time on multi-processor computers by launching a compile job on each available processor. Hence, compiling on a dual-processor computer will make the actual compile time about twice faster. The linking time, which may be pretty long, isn’t improved. 30

Project:Ω — Panther for Developers

Figure 2.8: The Xcode documentation browser.

Distributed Builds Distributed Builds is another smart feature introduced in Xcode. The concept isn’t new, but Apple has brought here its “legendary ease of use”. So, what’s the idea behind it? Distributed builds consist of taking advantage of other computers and asking them to help you compile the sources files. To make a long story short, you send your files to other hosts via the network, they compile the files for you and send them back for linking.

Please Note To be able to take advantage of Distributed Builds you need: · fast network connections (100Mbps or higher) · Xcode installed on all the hosts with the appropriate SDKs

Apple’s implementation of Distributed Builds uses the Open Source software distcc: ls -l /usr/bin/distcc* -rwxr-xr-x 1 root wheel -rwxr-xr-x 1 root wheel -rwxr-xr-x 1 root wheel

65744 23 Aug 01:59 /usr/bin/distcc 93048 23 Aug 01:59 /usr/bin/distccd 101720 23 Aug 01:59 /usr/bin/distccschedd

The software consists of several tools: distcc will create and send over the network selfcontained compile jobs to computers running the distccd daemon. “Jobs that cannot be distributed, such as linking or preprocessing are run locally”. The Apple touch makes the whole process as simple as checking one chechbox in the preference panel. The distcc tools have been tuned by Apple to take advantage of Rendezvous so you don’t need to do any configuration to send the files over your local network (Apple’s advice is to use at least a 100Mbps network connection, so distributing builds over the Internet is quite unrealistic). Chapter 2 : The Xcode IDE

31

But if you have other hosts on your LAN which are not on the same subnet, you still can add them manually. But what happens if you don’t want to see your precious source files spread over the whole network but you still want to take advantage of that dual-G5 PowerMac your colleague isn’t using during lunchtime? You still can benefit from the distributed build by sending the compile jobs to a number of selected hosts only. And what if you don’t want to overload your wife’s 233MHz G3-iMac or if you don’t want all your colleagues send compile jobs to your brand new PowerMac G5? Distributed builds aren’t activated by default, so you don’t have to worry. If you still want to be nice with your colleagues but not suffer from any overload, you can make your computer accept compile jobs but do the actual building as a low priority job (see figure 2.9).

Figure 2.9: the Distributed Builds configuration panel.

 Wrapping up Distributed Builds: · take advantage of the processing power of computers on the LAN · need at least a 100Mbps network connection · easy to setup, safe and secure · provides greatest benefits with 1 to 3 Macs

Useful URLs distcc homepage: distcc.samba.org distcc manpage: distcc.samba.org/man/distcc_1.html distccd manpage: distcc.samba.org/man/distccd_1.html disctcc part of Xcode: distcc.samba.org/news.html#2003-06-26

32

Project:Ω — Panther for Developers

Zero Link Not much information seem to be available about the Zero Link feature. The following information has been found in the Xcode Release Notes: ZeroLink eliminates the link step in building, and instead loads and links in .o files as the application is running. With ZeroLink, incremental builds are faster, but some applications may run or debug slower. By default, development builds of application use ZeroLink. To turn off ZeroLink, you must bring up the project inspector, click on the ”Styles” tab, select ”Development” build style, and uncheck the “Zero link”. How ZeroLink relates to other linking options may not be clear from the user interface. With ZeroLink, linking is done at runtime and is available only for development done from the IDE application. It cannot be used for linking of products that are to be run apart from the IDE application. Prebinding is incompatible with ZeroLink. Although the prebinding option appears to always be available in the user interface, this option is ignored when ZeroLink is being used. Options for linking with a two level or flat namespace are not available in the user interface, but work with ZeroLink. To use these options it is necessary to manually add linker flags to the ”Other linker flags” build setting that is with the linker settings in the list of standard build settings. If no namespace is specified, the ZeroLink defaults to flat. Add -twolevel namespace to use two level Zero linking. For C++ development with ZeroLink, add “-lstdc++” to “Other Linker Flags” in the “Common Settings” in the Target inspector.

The Inspector If you tried to follow the previous instructions and turn of Zero Link feature, you have discovered another change from ProjectBuilder: the Inspector (Figure 2.10). The aim of this tool is to give you a lot of information, to make this information always available and to let you change virtually every setting available for the files, projects, targets, and so on. What may be pretty confusing is that Xcode features an Info window (! I) and an Inspector window (! ! I) which give you the exact same information. In fact, the only difference is about their behaviour. The Info window behaves like the Info window of the Finder since Mac OS X 10.2 – which is bound to a file while the Inspector window behaves like the Info window of the Finder in Mac OS X 10.1 – which gives you the information of the currently selected file.

Fix and Continue Xcode’s debugger looks like ProjectBuilder’s one, but it is a lot more powerful and features the new and amazing Fix and Continue function, which can be enabled and disabled through the Inspector (Figure 2.10). Fix and Continue allows you to modify the source of your application while you are debugging it and to dynamically add the changes to the debug session without restarting the application. While Fix and Continue doesn’t apply to every kind of changes you can do, it is particularly well Chapter 2 : The Xcode IDE

33

Figure 2.10: the Inspector gives access to virtually any setting.

suited for logic bugs (like i instead of i++, && instead of ||, infinite loops, and so on). You can also make changes within functions, modify constants or local variable, and, even better, you can add or remove local variables and functions and actually call them! Of course, some limitations apply. The most important thing to keep in mind when using Fix and Continue is that you shouldn’t make any changes that will have a global effect on your application. This is why you can’t change headers, global variables and signatures. The changes which will obviously not work are those made in the layouts of structures and classes. These limitations are due to the very way Xcode dynamically loads the object files and libraries and links them to the running application. Changes which need runtime initialization will certainly not work since your application is not reloaded and hence the initialization will not occur. Fortunately, these limitations should be flagged in Xcode.

Please Note Fix and Continue is not available through the command line interface of gdb. For additional information, please refer to the Xcode Release Notes.

Debugger Data Formatters Another useful feature of the Xcode debugger is Data Formatters which allow you to get the data displayed in the debugger window the way you want it to. The Xcode Release Notes give all the needed information: 34

Project:Ω — Panther for Developers

Figure 2.11: The debugger’s new UI sports two different layouts – available from the Debug menu.

Xcode supports customizing the information displayed in the debugger data view. Developers can enter simple format strings which describe what to display in the variable value and summary columns on a per-type basis. These format strings are described below. Additionally, developers can write bundles which are loaded into the debugged process. This allows developers to write their own “print for debugger” functions which can be invoked via the format strings. [...] Take for example the NSRect produced by NSMakeRect(1,2,3,4). The format string:

x=%origin.x%, y=%origin.y%, width=%size.width%, height=%size.height%

would product the display:

x=0, y=1, width=2, height=3

For the complete documentation, please take a look to the Xcode Release Notes. Chapter 2 : The Xcode IDE

35

Performance Tools Integration Xcode now enables you to take advantage of some of the great performance and profiling tools available as part of Apple developer tools. Figure 2.12 shows how you can launch your application using Sampler, MallocDebug or ObjectAlloc. Additional information about performance tools are available in the section 2.6 (p.57).

Figure 2.12: Quickly launch your project using one of the performance tools

CVS and Perforce Integration CVS (Concurrent Versions System) and Perforce are Source Code Management (SCM) – also known as Version Control, Revision Control – systems. While SCM systems such as CVS usually allow you to store and manage any kind of plain text files (some systems also allow binary files), they are almost exclusively used by developers to manage their source code. Thanks to these systems, each version of any file you commit to the repository is logged and saved. Please note that the SCM server is not a file server – it doesn’t store a file for each version, it rather remembers the changes made on each version of the file. Hence, not only you have a backup of the sources in the repository but you can also check out any version of any file and take tracks of all the changes made to it. This is the reason why you should use an SCM system even if you are the only developer on the project. Of course, if you are part of a whole team of developers, using SCM is not an option anymore. While CVS is free software (distributed under the terms of the GNU Public License) and is widely used by developers for commercial and community projects (for example, Apple internally for Mac OS X, and almost any Open Source project, such as the Linux Kernel), Perforce, which is a commercial SCM, is also very popular. Recently, another project named Subversion has been gaining popularity. Its goal is to create a free (under Apache License) SCM system from scratch with state of the art design and many new features. The good old ProjectBuilder had a decent CVS integration but since SCM is crucial to developers, Apple has greatly improved its integration in Xcode. Perforce support has also been added due to popular demand from developers. This is the reason why the CVS menu has been renamed to SCM. An overview of the SCM properties of each file is given by the SCM pane of the Inspector (Figure 2.13). Xcode supports the most common operations and will make your life easier and your project safer. 36

Project:Ω — Panther for Developers

Figure 2.13: The SCM pane of the Inspector

Useful URLs · CVS homepage: ccvs.cvshome.org/servlets/ProjectHome · Perforce homepage: www.perforce.com · Subversion homepage: subversion.tigris.org

SDK Support Thanks to the new SDK feature of Xcode, it is now possible to develop and deploy on various versions of Mac OS X. This feature was really lacking in previous versions of Apple’s developer tools and if you wanted your software to support several versions of the OS with latest APIs available, you had to have several versions of Mac OS X installed on your computer. As we mentioned in the section 2.1 (page 25), you can now run Xcode on any supported OS version (for example, on Mac OS X 10.2) and build for the others available deployment targets (for example, build for Mac OS X 10.1). Obviously, you won’t want to develop on Mac OS X 10.2 and deploy on Mac OS X 10.3 if you want to take advantage of the new APIs of Panther even though Xcode makes this possible. You can specify a major version of Mac OS X as the deployment OS for each target of your project. Figure 2.14 shows how you do this using the project’s Inspector.

Chapter 2 : The Xcode IDE

37

The different SDKs installed by the Xcode CD are located in /Developer/SDKs. They are conveniently packaged in folders – allowing you to add and remove any SDK simply by drag-anddropping the folder. Each SDK contains the headers, frameworks and Stub Libraries of a given version of Mac OS X. The SDKSettings.plist file of each SDK has a marker which defines the version of Mac OS X against which you can link your software. Please note that the pop-up menu of the Inspector will show you a predefined list of OS versions no matter which SDK are installed on your computer. Please also note that if you use SDKs, your software will be weak-linked against the SDK and that you must perform sanity checks during runtime to determine if you can use the functions of the latest version of Mac OS X.

Figure 2.14: Use the project’s Inspector to set up the deployment target.

Useful URLs For in-depth documentation about SDKs, please refer too: file:///Developer/Documentation/DeveloperTools/Conceptual/cross development/index.html

Scripting Xcode

38

Project:Ω — Panther for Developers

You can automate many things in Xcode thanks to its built-in scripting support. Apple has worked a lot on providing as many tools as possible to make our life easier, automate daily (or even much more common) tasks. And not only has Xcode’s support of AppleScript been greatly improved, but you can also write script in any other language you feel more comfortable with. Xcode’s AppleScript dictionary has a rather impressive size and is quite complete. It contains many different suites which allow you to write virtually any kind of script from basic ones (such as simply starting a build) to much more complex AppleScripts such as the very impressive CodeWarrior importer which handles CodeWarrior project to export it in XML and then import it back in Xcode and create all the targets and build options. Among the other scripting languages you can take advantage of, you will find regular shell scripts , but also Perl and Python and thanks to the various command line developer tools, you are able to script virtually everything you do from the GUI. For more information about the command line tools, please refer to the section 2.5 (page 48). Another nice and unknown feature of Xcode is the ability to execute any shell command selected in the text editor by pressing the Control-R shortcut (see Figure 2.15 for an example). Hence, you can quickly execute a command at any time without having to switch back-andforth to the Terminal. Apple suggests that you can also keep a file containing commonly used commands to be even quicker.

Figure 2.15: Execution of the ls -lh /Developer in Xcode

One more thing Apple added to Xcode is a Script menu. This Script menu should be familiar to people who script other Apple applications such as iTunes. What you do to make the menu appear is to put your different scripts (it can a medley of AppleScript, Python, Perl and Shell Chapter 2 : The Xcode IDE

39

scripts) in the ~/Library/Application\ Support/Apple/Developer\ Tools/ folder – you will probably have to create the Scripts folder since it is not created by default. An example of Scripts menu is given on the Figure 2.16. For more information about the creation of this menu, its items and the keyboard shortcuts, please take a look at the Customizing Xcode Programming Topic.

Figure 2.16: The sample Scripts menu of XCode

Useful URLs Customizing Xcode Programming Topic /Developer/Documentation/DeveloperTools/Conceptual/CustomizingXcode/Scripts/Scripts.html

Native Targets To take advantage of all the new features we have mentioned – such as Fix and Continue, Zero Link, SDK support, Distributed Builds, etc. – a new dependency engine has been provided to Xcode. Xcode is still able to use the old JAM based targets but you won’t allow you take advantage of all its features. Creating a new native target from your old legacy one is very straighforward – all you have to do is select Upgrade Target to Native from the Project menu and type a name for the new target. Notice that Xcode helps you distinguish legacy targets from native one by showing two different icons: the target – which was used by ProjectBuilder – is used for legacy targets while the new generic application icon is used for Xcode native ones. The Target group’s icon is always the ancient generic target one, but the targets it contains use different icons to show their type. Please note that any new project or target created within Xcode is native. Before importing your ProjectBuilder into Xcode, make sure you have backed it up, because ProjectBuilder won’t be able to open it anymore. And finally, some limitations still apply to native targets. For example Java and AppleScript targets are not supported by Native targets yet. If you are planning to import CodeWarrior projects to Xcode, you will find valuable help in the Moving Projects to XCode documentation available with the developer documentation of Xcode: /Developer/Documentation/DeveloperTools/Conceptual/MovingProjectsToXcode/ ¬ MovingProjectsToXcode.pdf 40

Project:Ω — Panther for Developers

InterfaceBuilder 2.4 InterfaceBuilder is primarily Apple’s application to design graphical user interfaces. It has many features which will help you follow Mac OS X Human Interface Guidelines . It was particularly suited for building great Cocoa interfaces but a lot of work has been done about Carbon GUI design and now InterfaceBuilder is also doing great job designing Carbon application GUIs. InterfaceBuilder helps you take advantage of the power of Cocoa and reduce the amount of code you write.

Updates for both Carbon and Cocoa As we already mentioned several times in the previous sections, Apple has put a lot of work on improving the “cross-platform” abilities of its developer tools – cross-platform meaning the ability to build for various major versions Mac OS X and not for other operating systems. That’s the reason why Apple introduced the SDKs in its developer tools. But it wouldn’t have been complete, because depending on the version of InterfaceBuilder, you can use functions and widgets which may not be available on previous releases of the OS. In fact, this was a real issue until now. In version 2.4, Interface Builder has built-in compatibility checking and the best part is that it’s very easy to use and discover what you will need to change in order to make your software run on a given version of Mac OS X. All you have to do is select the new Nib tab of your nib window and select the Nib file format you want to use and then select the oldest deployment target to discover the incompatibilities you have to fix (see Figure 2.17). It even details what you have to change to make your software compatible with the versions you are targeting (see Figure 2.18)! The other major new feature is system wide: Mac OS X 10.3 has introduced another size of controls (or widgets) called Mini Controls. So now, you have three different sizes for most widgets: the regular or normal one, the small one and the new mini one. Note that not all the controls have a mini version. Figure 2.19 shows you the various size of controls available and you can appreciate the benefits of each size in terms of space saved (the red arrows give you the number of pixel saved). Please read the Human Interface Guidelines to avoid any misuse.

Useful URLs Mac OS X Human Inteface Guidelines: /Developer/Documentation/UserExperience/Conceptual/AquaHIGuidelines/AquaHIGuidelines.pdf

Updates for Cocoa InterfaceBuilder introduces several new widgets such as the Search Field and many new customization which were done programatically before Mac OS X 10.3. Figure 2.20 shows most of them. Among the very anticipated features you will find the ability to alternate the background color of NSTableView rows (Figure 2.21), the introduction of data cells and sort ordering for the NSTableColumns, placeholders for NSTextFields and the new NSSearchField. NSTextViews can now easily use the standard Find Panel. Several new palettes have also been created for InterfaceBuilder. The most important being the Controller Palette which will be used with the new binding feature, the AddressBook Palette which makes it very easy for you to add the features of the AddressBook to your application and Chapter 2 : InterfaceBuilder 2.4

41

Figure 2.17: The new Nib tab help you fix incompatibilities

Figure 2.18: The Incompatibility window gives you important details

the WebView which lets you embed and use the WebKit features into your software. And adding or removing support of plug-in, Java, JavaScript or Pop-up blocking is as simple as checking a checkbox (Figure 2.21). The next section will be very simple and graphical tutorial which will show you the real power of the new AddressBook Palette.

AddressBook Palette tutorial Launch InterfaceBuilder. If the AddressBook Palette isn’t already loaded, locate it in the /Developer/Extras/Palettes directory and double-click on it. It should then appear in InterfaceBuilder’s palette window. Create a new Cocoa Application (! –N), and add an ABPeoplePickerView to the NSWindow. Now choose Test Interface (! –R) and notice that the ABPeoplePickerView is loaded and amazingly functional: the groups and contacts of your personnal AddressBook are listed and the SearchField is operational. Try Control-clicking on a contact’s name and notice that a functional contextual menu appears. The Edit Card item opens the selected contact in the AddressBook application and lets you edit it and, even more amazing, the Export vCard opens a sheet which lets you save your contact as a vCard. Notice that we haven’t written any line of code and that we didn’t even compile any project! Figure 2.22 shows you the ABPeoplePickerView before and after the Test Interface command and we take advantage of the situation to show you some other widgets which are new in Mac OS X 10.3 42

Project:Ω — Panther for Developers

Figure 2.19: Size does matter

Figure 2.20: Notice the new widgets

Cocoa Bindings Cocoa Bindings is a major new feature of Panther which has been created to reduce the amount of “glue code” developers write. Usually, it is now well know that many UI objects (text fields, sliders, tables, etc.) are used to reflect the value stored in variables and may have different behaviors depending on this very value (for example, a checkbox may be disabled or not, a text field may be invisible, etc.). This is the reason why Apple decided to provide a technology which will allow developers to develop much faster by binding these values to the widgets directly from InterfaceBuilder. Please refer to the AppKit release notes for more information about Cocoa Bindings. You do this in InterfaceBuilder thanks to the NSController classes, the Binding pane of the Info window and the Controllers palette. In order to give you a preview of this technology, we will build a web browser (yes, a real web browser) thanks to the new WebKit view of Interface Builder. All this will be done very easily in InterfaceBuilder so you won’t even have to write a single line of code nor compile any project. Chapter 2 : InterfaceBuilder 2.4

43

Many features of the NSTableView can now be managed with the info window of IB

Notice how powerful and yet how simple the WebView is. You can easily add or remove many features to your web renderer

Notice how easy it has become to use alternate row background for NSTableViews

Figure 2.21: Notice the new widgets

WebView tutorial · Launch InterfaceBuilder Locate InterfaceBuilder in the /Developer/Applications folder and launch it. Select Application under the Cocoa disclosure triangle and click on the New button. An untitled IB “project” containing everything you need to build your browser will be created. · Place the URL field Drag an NSTextField on the Window from the Cocoa-Text pane. Use the guidelines to position it correctly in the upper left corner. Then, drag and drop a WebView from the Cocoa-GraphicsView panel to the window. Use the auto-sizing panel of the Size item of the Info window to bind the WebView so it shrinks and enlarges when you resize the main window. Fix also the URL field in the main window so it doesn’t resize or move when the window is resized. · Connect the NSTextField to the WebView Hold down the Control key while dragging the mouse from the NSTextField to the WebView. In the Connections item of the Inspector window, under the Target/Action tab, click on takeStringURLFrom: and click on the Connect button (Figure 2.23). Hence, the string typed in the NSTextField will be sent as the URL that the WebView will load. Note that this URL must be a complete one – i.e. the http:// prefix has to be typed in the field. Notice that your browser is already working: typing an URL in the field will actually load the 44

Project:Ω — Panther for Developers

The new borderless pop-up menu

The new placeholder feature available for NSTextFields and other widgets

Your groups and contacts automatically appear here

The search field works great The contextual menu reveals two functional features

Figure 2.22: The incredible AddressBook Palette

page inside de WebView and you can browse the page, everything works... or almost: the browser is still far from complete: you don’t have a load progress indicator, when browsing the URL doesn’t change in the URL field to reflect the page you’re seeing, you don’t have stop, next, previous buttons, etc. This is what we will add now. · First Bindings First, add a Stop NSButton to your window. Connect the Stop NSButton to the WebView Chapter 2 : InterfaceBuilder 2.4

45

Figure 2.23: Create your own browser with WebKit embedded

and connect it the stopLoading: action. Test the interface (!-R) and notice that the Stop button actually stops the loading of the page. But there still is something wrong with this button: it is always enabled even though there is nothing to stop. Let’s fix this small issue and discover the power of Bindings. Select the NSButton in the main window and then, in the Info window, select Bindings (!-4). You will notice different subsections and parameters. We are interested in the Availability parameter of the Stop button. We want it to be disabled when there the browser is idle. Click on the Enabled label of the Availability section. New parameter will be disclosed. Select WebView in the Binding pop-up menu. Then isLoading in the Model Key Path one (Figure 2.24). The button is now bind to the WebKit view and, as you probably have guessed it, it will be disabled when nothing is loading. Very straightforward and no glue-code! Also bind the Value of the NSTextField to the mainFrameURL Model Key Path of the WebView Binding. Now, the NSTextField will be automatically assigned its string value by the WebView while browsing. You can give it a try (!-R). You have noticed that this would have been easy to implement (a few lines of Cocoa code) but why would you trouble doing so, when it is so easy to do it from InterfaceBuilder? · Create a more complete interface As you might have seen while binding the previous elements, there are some more Model Key Path provided by the WebView binding which will allow you to add other useful widgets to your browser. Take a few minutes (seconds?) to add Back and Forward buttons which are only available when usable, add widgets to increase and decrease font size, and finally add a circular progress widget to let the user know that the page is loading and another one to indicate the actual level of loading. 46

Project:Ω — Panther for Developers

Bind the 'enabled' availability feature of the Stop button to the WebView's isLoading key and set the button's target to the stopLoading: action of the WebView

For a real web browsing experience, bind the NSTextField's value to the mainFrameURL of the WebView

Figure 2.24: The new binding feature is unbelievably powerful

47

Chapter 2 : InterfaceBuilder 2.4

· Enjoy Once you have added all the elements you wanted, your browser might look like the one on the Figure 2.25. Take a few minutes to enjoy browsing the Web with your own browser and also to think of all the new powerful applications you can write very quickly thanks to great features such as WebKit and Cocoa Bindings.

Updates for Carbon InterfaceBuilder 2.4 has been improved for Carbon development. We won’t go into much details about the changes for Carbon, but here is the major ones. · New widgets and views InterfaceBuilder 2.4 adds support for HISearchField, HIImageView, HITextView, HIComboBox, HIScrollView, HIView, HelpButton. Note that the HIScrollView is limited to HIImageView and HITextView in the current release of InterfaceBuilder. · New Property editor The Info window of InterfceBuilder 2.4 has a new property editor in its Control pane. It allows you to set several values for each of the Creator, Tag, Type and Value fields of a given control. · Many new attributes supported InterfaceBuilder 2.4 supports new attributes for menus and menu items.

Useful URLs For more information about Carbon GUI building with InterfaceBuilder 2.4, please read InterfaceBuilder’s release notes: /Developer/Applications/Interface Builder.app/Contents/Resources/¬ ReleaseNotes/InterfaceBuilder2.4.rtf

Command Line developer tools Apple provides many useful CLI developer tools which are often not known or used by many developers I’ve met. We will try to list them here and give you some tips so you can take advantage of them and make your development work more efficient. Let’s start by those installed in /Developer/Tools. These tools are not by default in your PATH env var. The following .tcshrc file gives an example on how you can add them to you path: % cat ~/.tcshrc setenv PATH {$PATH}:/usr/local/bin:/opt/local/bin:/Developer/Tools % cat ~/.bashrc PATH={$PATH}:/usr/local/bin:/opt/local/bin:/Developer/Tools · agvtool agv stands for Apple generic versioning. agvtool was used in ProjectBuilder and now in 48

Project:Ω — Panther for Developers

Figure 2.25: The best web browser on the planet?

Chapter 2 : Command Line developer tools

49

Xcode to speed up operations for projects using the apple-generic versioning system. You must enable this versioning support in the expert build settings of your project on a per-target basis. For more information about agvtool please type agvtool help in the Terminal. · BuildStrings Currently no information available · CpMac CpMac is a command equivalent to the cp Unix command except that it is metadata and fork aware. Hence, you can copy older files which still have resource forks such as Mac OS 9 applications. The -r option is available for recursive copies and the -p option tries to preserve the metadata such as the modification and creation time and other flags (depending on the access permissions the issuer of the command has). · cvs-wrap and cvs-unwrap cvs-wrap wraps a directory into a gzipped tar file while the reciprocal extraction is handled by the cvs-unwrap command. · cvswrappers

Please Note: Adding nib files to a CVS repository Nib files are binary files so adding them to a CVS repository may lead to issues. The IB FAQ provides the solution: “The easiest way to add a nib file to a cvs repository is to use CVSWRAPPERS. Simply create a .cvswrappers symlink in your home directory that points to the cvswrappers file located in the /Developer/Tools directory. ln -s /Developer/Tools/cvswrappers /.cvswrappers You can now add nib files to a cvs repository the same way you do with regular files.”

· Rez and DeRez Rez is a CLI tool used to compile the resource fork of a file according to the textual description contained in the resource description files, like in the old Mac OS 7. DeRez do the opposite job: decompiles the resource fork according to the type declarations supplied by the type declaration files. For more information about Rez or DeRez, read the corresonding man page. · GetFileInfo GetFileInfo is a CLI tool used to get the HFS+ file attributes. For more information about GetFileInfo, read the corresponding man page. Here is an example: GetFileInfo ~/Music file: "/Users/pejvan/Music" type: "fdrp" creator: "MACS" attributes: Avbstclinmed created: 08/21/2003 00:33:42 modified: 08/21/2003 00:33:42

50

Project:Ω — Panther for Developers

· MergePef Merges two or more PEF files into a single file. PEF format is used for Mac OS 9 code (or CFM apps). · MvMac MvMac is a command equivalent to the mv Unix command except that it is metadata and fork aware. Please take into account that a bug prevents it from working across volumes/filesystems. · pbhelpindexer Indexes the HTML documentation generated by HeaderDoc in order to let ProjectBuilder and Xcode find the appropriate excerpt for a given symbol. · pbprojectdump Takes a ProjectBuilder (.pbproj) or an Xcode (.xcode) project file and outputs a more nested version of the project structure. The following is the beginning of such an output: % pbprojectdump new-cocoa.xcode { archiveVersion = 1; classes = {}; objectVersion = 39; rootObject = { buildSettings = {}; buildStyles = ( { buildRules = (); buildSettings = { "COPY_PHASE_STRIP" = NO; "DEBUGGING_SYMBOLS" = YES; "GCC_DYNAMIC_NO_PIC" = NO; "GCC_ENABLE_FIX_AND_CONTINUE" = YES; "GCC_GENERATE_DEBUGGING_SYMBOLS" = YES; "GCC_OPTIMIZATION_LEVEL" = 0; "OPTIMIZATION_CFLAGS" = "-O0"; "ZERO_LINK" = YES; }; isa = PBXBuildStyle; name = Development; }, { buildRules = (); buildSettings = { "COPY_PHASE_STRIP" = YES; "GCC_ENABLE_FIX_AND_CONTINUE" = NO; "GCC_PRECOMPILE_PREFIX_HEADER" = NO; "LIBRARY_STYLE" = Static; "ZERO_LINK" = NO; }; isa = PBXBuildStyle; name = Deployment; } ); hasScannedForEncodings = 1; isa = PBXProject; [...]

Chapter 2 : Command Line developer tools

51

}

· pbutil Checks to make sure all the files on a disk are in a project, or lists all the groups and files in a project. Use the -dumpGroups option to dump all the groups and files of a project, and the -diskToProject option to check if the file in the current directory are in the project.

% pbutil -dumpGroups new-cocoa/ Classes/ Other Sources/ new-cocoa_Prefix.pch main.m Resources/ Info.plist InfoPlist.strings/ English MainMenu.nib/ English Frameworks/ Linked Frameworks/ Cocoa.framework Other Frameworks/ Foundation.framework AppKit.framework Products/ new-cocoa.app test-sdk.app

· pbxcp pbxcp is copy tool like CpMac and cp except that it has many useful options letting you skip specified files, strip debug symbols, preserve some metadata, resolve symlinks and attempt to apply chmod, chown and chgroup to the files (some features not implemented yet). · pbxhmapdump Dumps to standard output the contents of the .hmap file (which gives you the full path of all headers of the project) created by xcodebuild or by the Xcode application. % pbxhmapdump Ports\ Manager.hmap [...] PMStatusView.h -> /Users/pejvan/PortsManager/PMApp/PMStatusView.h DPObject.h -> /Users/pejvan/PortsManager/DPTool/DPObject.h PMConsole.h -> /Users/pejvan/PortsManager/PMApp/PMConsole.h DPAgentProtocol.h -> /Users/pejvan/PortsManager/DPTool/DPAgentProtocol.h DPApp.h -> /Users/pejvan/PortsManager/DarwinPorts Installer/DPApp/DPApp.h PMBrowser_Toolbar.h -> /Users/pejvan/PortsManager/PMApp/PMBrowser_Toolbar.h PMPrefs.h -> /Users/pejvan/PortsManager/PMApp/PMPrefs.h [...]

· ResMerger Merges Resource Manager resources into resource files. Also used by Xcode 52

Project:Ω — Panther for Developers

· RezWack and UnRezWack The tools are part of the QuickTime 3 Software Development Kit for Windows. · sdp sdp stands for Scripting Definition Processor. It is used to convert an AppleScript dictionary file into other formats. For more info, man sdp. · SetFile SetFile sets the attributes of files in an HFS+ directory. It does the reciprocal job of GetFileInfo. For more info, man SetFile. · SplitForks Strips off the resource fork of the specified file and saves it as a hidden file with the same name but prefixed by ’. ’ (dot-underscore). · uninstall-devtools.pl A Perl script you will use if you want to uninstall the developer tools provided by the Xcode CD. · WSMakeStubs Generates stubs for use with WebServices.framework. There are two command line tools used by Xcode which are really rarely used by the end-user. There are located in the /Developer/Private folder. · jam jam is an open-source build system initially released by Perforce and used by Xcode. More information available from http://www.perforce.com/jam/jam.html. · pbhelpindexloader % /Developer/Private/pbhelpindexloader -h pbhelpindexloader [fileSystemRoot] pbhelpindexloader reads stdin for a textual version of the documentation index and writes out a binary representation of that data, which PB can use for documentation lookup. The optional argument specifies a path to use as if it were the root file system. If it is not specified, "/" is used.

And finally, let’s talk about the Mac OS X specific developer tools located in /usr/bin. Appendix A: Categorized CLI developer tools provides a categorized ordering of these tools. · compileHelp The compileHelp command-line utility is provided for legacy applications in order to merge contextual help rtf snippets into one resource. For more information, please try to man compileHelp. · genstrings genstrings is used to generate .string files used for localization purposed from C, ObjectiveC and Java source code, provided that you have used the Localization functions available in CoreFoundation or Cocoa (both Objective-C and Java). For more information, please try to man genstrings. Chapter 2 : Command Line developer tools

53

· headerdoc2html headerdoc2html processes the header files and generates HTML documentation based on specially-formatted comments. For more information, please try to man headerdoc2html. For more information about Apple’s HeaderDoc documentation project, please refer to http://developer.apple.com/darwin/projects/headerdoc/. · libtool The libtool command creates a library – dynamically linked shared or statically linked, as you want – from the object files used as input. The libraries generated by libtool can then be used with the ld link editor. Shared libraries are Mach-O only files whereas statically linked libraries can be ar format. For more information, please try to man libtool.

Please Note – libtool and the GNU libtool It is very important to understand the the libtool provided by Mac OS X is different from the GNU libtool. Do not switch them. % ls -l /usr/bin/ -rwxr-xr-x 1 root -rwxr-xr-x 1 root -r-xr-xr-x 1 root lrwxr-xr-x 1 root

| grep libtool wheel 206160 31 Aug 03:00 glibtool wheel 9927 31 Aug 03:00 glibtoolize wheel 126448 9 Oct 23:55 libtool wheel 7 9 Oct 23:47 ranlib -> libtool

· mkdep mkdep is used to construct Makefile dependency lists. For more information, please try to man mkdep. · osacompile osacompile compiles AppleScripts and other OSA language scripts. For more information about this CLI tool, please try to man osacompile. · osascript osascript executes AppleScripts and other OSA language scripts from the command line. Very useful in shell scripts for example. For more information about this CLI tool, please try to man osascript. For more information about the installed OSA languages, please try to man osalang. Here’s an example of the osalang output: % osalang -L ascr appl cgxervdh AppleScript (AppleScript.) scpt appl cgxervdh Generic Scripting System ¬ (Transparently supports all installed OSA scripting systems.)

· plutil plutil stands for Property List Utility and is used to check the syntax of property list files or convert a plist file from one format to another. For more information about plutil, please try to man plutil and for more information about plist files, man plist. · ranlib and ar ranlib and ar are used for backward compatibility only. You should rather use libtool -static which is intended to replace them. For more information, please try to man ranlib, man ar and man ld. 54

Project:Ω — Panther for Developers

· RCS The GNU RCS is installed with the developer tools – if you’re not familiar with RCS, you can read the RCS introduction by typing man rcsintro in the Terminal or browse the follwing web sites: www.cs.purdue.edu/homes/trinkle/RCS/ and www.gnu.org/ software/rcs/rcs.html. RCS provides the following tools: rcsintro, rcs, rcsfile, ci, co, rcsdiff, rlog, rcsmerge, rcsclean and rcsfreeze. Please man any of these tools for more information. · redo prebinding and update prebinding update prebinding ensures that prebinding information is up-to-date after new prebound applications or new versions of system libraries are installed (man update prebinding) while redo prebinding is used to redo the prebinding of an executable or a dynamic library when one of the dependent dynamic libraries changes (man redo prebinding). For more information about prebinding , please take a look at the first chapter of the MachO Runtime documentation, available in the /Developer/Documentation/DeveloperTools/Conceptual/MachORuntime/ folder. · tops tops is a powerful tool used to perform substitutions (find and replace) on strings in text files (in source files, for examples). For more information about tops, please try to man tops. · xcodebuild xcodebuild is used to compile Xcode project from the command line. Its usage is really straightforward provided that you have read the the short manual: man xcodebuild. For an example, please have a look at section 1.4.3.

Please Note Please note that xcodebuild replaces the pbxbuild and it seems that unlike what Apple’s documentation states, there is symbolic link targeted on xcodebuild and named pbxbuild. If you have written scripts which used pbxbuild under previous versions of Mac OS X, please create the link: % sudo ln -s /usr/bin/xcodebuild /usr/bin/pbxbuild

· Common scripting tools Of course, virtually any scripting tool is provided with Mac OS X: perl, awk, python, ruby, sed, tcl etc. · Perl tools a2p which converts awk scripts to Perl ones, s2p, which converts sed scripts to Perl ones, perlcc which generates executables from Perl scripts. For more information about this CLI tool, please try to man perlcc. And the complete perlpod package for documentation. For more information about this perlpod and the related tools, please try to man perlpod. To obtain the list of all the man pages of the comprehensive Perl documentation, please try to man perl. · Common parser and lexical anyliser generators flex, lex, (and flex++ and lex++ as symlinks to flex and lex), bison, yacc. · BOM utilities The lsbom command interprets the contents of binary bom files. Chapter 2 : Command Line developer tools

55

The mkbom command interprets the contents of the directory given as input and generates the corresponding bom information. For more information about the bill of materials, please try to man bom. For more information about the lsbom, please try to man lsbom. For more information about the mkbom, please try to man mkbom. Next is an example of the lsbom command ouput: % pwd /Library/Receipts/iTunes.pkg/Contents % ls Archive.bom Info.plist Resources % lsbom Archive.bom . 41775 0/80 ./Applications 40775 0/80 ./Applications/iTunes.app 40775 0/80 ./Applications/iTunes.app/Contents 40775 ./Applications/iTunes.app/Contents/Info.plist ./Applications/iTunes.app/Contents/MacOS ./Applications/iTunes.app/Contents/MacOS/iTunes ./Applications/iTunes.app/Contents/PkgInfo ./Applications/iTunes.app/Contents/Resources [...]

version.plist

0/80 100664 40775 100775 100664 40775

0/80 0/80 0/80 0/80 0/80

12586

1842097018

4330652 2646984623 8 187102783

· installer and softwareupdate installer is the command line version of the standard Mac OS X Intaller and softwareupdate is the command line version of the SoftwareUpdate application. Please read the corresponding corresponding man pages for more information. Please note that the man installer seems to be inaccurate. Use the installer’s help instead: installer -help Usage: installer [options...] -pkg -target The options are: [-volinfo] # Display volumes that can be installed onto. [-pkginfo] # Display package that will be installed (for metapackages, ¬ shows contents). [-allow] # Allow installing an older version of a package over a newer ¬ one (for package versioning). [-dumplog] # Write log information to standard error (in addition to the ¬ usual syslog. [-help] # Display this help information. [-verbose] # Display detailed (verbose) information. [-verboseR] # Display detailed (verbose) information with simplified ¬ progress output. [-vers] # Display this tool version. [-config] # Display command line parameters in XML plist format. [-plist] # Display -pkginfo or -volinfo in XML plist format (ignored ¬ when performing installation). [-file ] # Configuration file supplying parameters in XML plist format. [-lang ] # Sets the default language Mac OS X will use after installation. [-listiso] # Lists the ISO language codes that are recognized. Examples: installer -pkg InstallMe.pkg -target ’/Volumes/Macintosh HD2’ -lang ja installer -volInfo -pkg InstallMe.pkg

56

Project:Ω — Panther for Developers

% softwareupdate --help Software Update Tool Copyright 2002-2003 Apple Computer, Inc. usage: softwareupdate [-q] Options: -q Quiet mode Commands: -h | --help Print this help -l | --list List all available updates -d | --download Download (to directory set in InternetConfig) -i | --install Install (requires root) ... specific updates -a | --all all available active updates -r | --req all required active updates --ignored Manage ignored updates list (per-user) add ... specific package names remove ... specific package names remove (-a | --all) all currently ignored package names --schedule Manage scheduler preferences on | off Set automatic checking (per-user)

Please Note CLI tools related to software profiling and debugging or performance improvement are listed in the section 2.6. It seems that the CLI versions of PackageMaker and systemsetup are not available in Mac OS X 10.3, which contradicts several man pages and the developer documentation.

Useful URLs For comprehensive information about the CLI developer tools, please read the Tools Overview (available in both HTML and PDF formats): /Developer/Documentation/DeveloperTools/Conceptual/ToolsOvr Book/ToolsOvr Book.pdf

Performance and Profiling Tools As you may have noticed, each new major version of Mac OS X provides a real speed boost and many performance improvements. I must admit that when I installed Mac OS X 10.1 I was amazed by its speed compared to the 10.0. When Mac OS X 10.2 was released, I was thinking that Mac OS X couldn’t become any faster. But once again, with the release of Mac OS X 10.3 Panther, there has been a notable speed boost. But Mac OS X isn’t the only software Apple is focusing on and trying to speed up. For example, with the release of WebKit and Safari 1.0, Apple showed that it was possible to write a real fast Mac OS X web browser with a very small footprint. They reached that goal by focusing on performance and optimization. And the best part is that all the tools (or, at least, most of them) used in order to achieve this goal are available for free to the developers. As users, we want our applications to be fast and responsive. This is how we get more productive and – something really important – actually enjoy working with our computers. That’s Chapter 2 : Performance and Profiling Tools

57

the reason why we must, as developers, focus on bringing the fastest and most optimized software to the users. Hopefully, Apple tries hard to get the developers reach that goal by providing best of breed performance, profiling and debugging tools. But optimization isn’t easy and improving performance of a software can be a tricky job. By introducing to you the tools provided as part of Apple’s developer tools, we try to get you to know were to start when you want to find the weaknesses of your software. Once you know which tools are available, you can use the most appropriate ones on a per case basis to locate the bottlenecks, memory leaks, and parts which need optimizations. As usual, we will also point you to the relevant developer documentation so you know where to find further and more in-depth information for your needs. During the next two sections, we will first introduce the Performance tools and then the CHUD tools which are now part of the Xcode CD.

The Performance Tools MallocDebug As obvious as it may seem, MallocDebug is an application which dynamically tracks the memory usage of a given application (and, by extension, memory allocations since a given time) in order to find memory leaks. A special version of the malloc() function is defined in the /usr/lib/ libMallocDebug.A.dylib and in the /usr/lib/libMallocDebug.a files. These libraries allow MallocDebug to retrieve valuable information about the memory allocations. The MallocDebug dynamically links the application you want to profile against the dylib. The static library can be used to link your application against and then attached by MallocDebug while your appliation is already running (specially useful when your application doesn’t use the System framework and will be statically linked against malloc). MallocDebug keeps track of all the memory allocations in a ”conservative garbage collector” (as Apple calls it) and then, in order to find memory leaks, it goes through memory blocks references by the pointers. When a memory block isn’t pointed by any pointer, it is considered as a leak. The other very nice feature of MallocDebug helps you find memory overruns/underruns. These nodes are the one that have been written incorrectly (past the end of or before the start of a node). A helpful hint can be found the in the Help file of MallocDebug: ”Many of these errors are the result of using the result of strlen(s) as the argument to malloc for a string instead of strlen (s) + 1.” Much more information about the usage of MallocDebug (more features, details about the GUI, technical information about the way it works and intrinsic limitations of the algorithm used) and many tips and tricks about memory management can be found in the Help files available from the Help menu of the application. These files tend to deal about the same things and are really complementary – let’s hope they will be merged into one single ReadMe files in the next release. ObjectAlloc

58

Project:Ω — Panther for Developers

Figure 2.26: MallocDebug helps you find bugs and improve your code

ObjectAlloc is a small yet very useful memory allocation monitoring tool. You can have a live update or not, and decide to get updates from a specified mark. The main window lets you switch back and forth from three different views: the “Global Allocations” tab, the “Instace Browser” and the ”Call Stacks” ones. ObjectAlloc will run with application using CoreFoundation or written in Cocoa. Not much information about ObjectAlloc is available but the Info.rtfd which is displayed in the ’about’ box. You can open it in TextEdit for better readability by typing open -e "/Developer/Applications/Performance Tools/ObjectAlloc.app/Contents/ Resources/English.lproj/Info.rtfd” in the Terminal.

Figure 2.27: ObjectAlloc shows memory (de-)allocations in real time

Chapter 2 : Performance and Profiling Tools

59

Quartz Debug Quartz Debug is a tool which will flash updated regions of the screen (yellow for updated regions and red for identically updated regions). This can be useful when you use custom views or manually refresh some of your windows. It can also be helpful by letting you see the way complex GUI elements such as the NSTableView behave and update their components. If you think that your application should behave faster, it’s often a good idea, specially if you draw manually in custom views, to check and see if you’re not doing duplicate drawings or too many refreshes.

Sampler The best description of Sampler probably comes from its ‘about’ box: “Sampler is a tool for understanding an application’s running behavior. It can identify where the program spends its time executing. It can also study the usage patterns of functions including allocation, copying, locking, IPC, or even user defined functions.” Sampler is a real complex utility which will let you profile several aspects of your application. The help file – available from the Help menu – gives a complete overview and many details about the concepts. The new version released with Panther and Xcode has major improvements compared to the previous releases and it’s definitely worth taking a look at its features.

Spin Control Spin Control is a brand new application released with the Xcode developer tools CD. You are probably familiar with what Apple calls the spinning rainbow wait cursor – and what many other people prefer calling the spinning beach ball of death – which appears when an application stop being responsive to the user – should it be because it is hung or has crashed. Spin Control will help you solve the first of these very annoying behaviours. You sure know that, in an end-user perspective, applications which sporadically hang and display the spinning beach ball are very annoying and such behavior will contribute in a bad user experience – no need to mention crashing applications here. Spin Control will help you improve your product by tracking down these cases by noting each time CoreGraphics detects an application as unresponsive – that is, CoreGraphics displays the spinning beach ball – and samples that application to allow the user to figure out the reason why it was hanging. Once again, a small help file is available in the Help menu of the application.

60

Project:Ω — Panther for Developers

Figure 2.28: SpinControl helps you improve the user experience of your product

Thread Viewer Thread Viewer lets you study the behavior of the threads within a specified application. You can attach it to a process which is already running or launch a new one with it. You will then see a timeline view which displays the different threads of the process and will color them in various colors depending on their activity. For example, running threads will be displayed in green while waiting ones will be displayed in different declinations of gray if they have been waiting since the last time they were examined: red if waiting on a lock or semaphore, blue if suspended, etc. For more comprehensive information about Thread Viewer, check the help file which is available in the Help menu of the application.

The CHUD Tools The CHUD (Computer Hardware Understanding Development) tools are Apple’s best of breed profiling tools and applications. They used to be available as a distinct download package (and are still available from ftp.apple.com/developer/Tool_Chest/Testing_-_Debugging/Performance_tools) and are now part of the Xcode CD (the latest version of the CHUD tools is 3.0.1 as of the writing of this document). It seems obvious to any Mac OS X developer that Apple is doing its best to improve the performance of its own products. And it is even more obvious that they are succeeding in this field, since each new major version of Mac OS X is so much faster and smoother. They are introducing many new technologies and optimized libraries not only to improve their own products, but also yours. This is the reason why they

Chapter 2 : Performance and Profiling Tools

61

are releasing those libraries as frameworks and they are making tools such as the CHUD tools available to any developer. The CHUD tools are the typical tools that Apple’s development team use internally – and I’ve heard so many developers tell this story at the WWDC, for example. This is the very evidence which you needed to believe in their usefulness.

BigTop BigTop is a new member of the CHUD tools. Basically, it’s a GUI based applications which provides the same information as the the top CLI tool but, unlike the Activity Monitor, which displays the results of top in a table-view, BigTop draws nice graphical representations of the same values and hence let you study the behavior of a given process or of the whole system during a certain amount of time.

Figure 2.29: BigTop is the graphical equivalent of the top CLI tool

62

Project:Ω — Panther for Developers

MONster MONster is a very low-level application which will monitor the PowerPC processors system controllers, etc. All the performance data which is collected can be processed by MONster in order to extract valuable information and you can save/export entire sessions to analyze them later. MONster comes with a detailed guide available as a PDF file from /Developer/ Documentation/CHUD/MONsterUserGuide.pdf or from its Help menu.

PMC Index PMC Index is a small application which lets you search the event database and get information about the PMCs (Performance Monitor Counters) of the processor. Currently, there is no information about PMC Index available.

Saturn Saturn is another profiling application which will show you the call tree of your code. As with MallocDebug, Saturn provides a static library – /usr/lib/libSaturn.a – against which you can compile your code with the -finstrument-functions flag of gcc and a dynamic one – /usr/lib/libSaturn.dylib. As explained in the documentation, once your application is compiled with the static library, it will automatically generate special files (with the .sat extension) which will then be visualized by the Saturn application. Saturn comes with a detailed guide available as a PDF file from /Developer/Documentation/CHUD/ SaturnUserGuide.pdf. This small document (10 pages) will give you an overview of Saturn and help you understand how you can optimize your application.

Shark Shark is probably the most complex and most useful application among the CHUD tools. Once again, it’s a profiling tool which will help you understand were your product can improve and be optimized. But unlike the other CHUD utilities, this one goes a lot further in the analysis. First of all, it profiles the entire system – including the various drivers and the kernel itself. What is really impressive is that Shark will actually find out were you can improve the performance of your product and will even advice you about the changes you can do! Shark comes with a detailed guide available as a PDF file from /Developer/Documentation/CHUD/ SharkUserGuide.pdf. This is quite a comprehensive guide (70 pages) which gives you not only many details about Shark but also provides general optimization knowledge for developers (specifically about PowerPC code optimization) and study cases among which the quite famous Flurry optimization session (The Flurry screensaver is part of Mac OS X since the 10.2 release).

Chapter 2 : Performance and Profiling Tools

63

Figure 2.30: Shark tries to help you improve your product’s performance with its advices

CacheBasher CacheBasher is an application which will measure the cache performance of the computer on which it runs. The test performed is highly customizable.

Skidmarks GT Skidmarks GT is an application which will measure the performance of the integer, floatingpoint and vector units of the type of processor built into your computer.

Reggie SE Reggie SE is a GUI application which allows you to view and edit the CPU and PCI configuration registers. This application should obviously be used with care. Please do not play with it if you don’t know what the consequences of the changes will be. Reggie SE comes also in a command line version: reggie se.

64

Project:Ω — Panther for Developers

SpindownHD SpindownHD is a small utility which allows you to view the state of the various ATA and ATAPI drives and edit the idle time after which they are put in sleep mode by the system.

CHUD CLI tools The CHUD package also include a few CLI tools which may prove themselves quite useful. amber and acid are respectively a TT6/TT6E/FULL instruction traces generator and analyzer. For more information about these tools please read their man pages. For more information about the trace formats used by amber, please read the AmberTraceFormats.pdf file, located in /Developer/Documentation/CHUD/. simg4 is a cycle-accurate Motorola PPC 7400 (the first G4 processor) simulator. Thanks to this tool, you can see the behavior of the processor cycle after cycle. simg4 can take a TT6 trace as input. For more information, please read the Sim G4 Users Guide.pdf file, located in /Developer/Documentation/CHUD/. simg5 is the equivalent of simg4 but for the PowerPC 970 processors and it has been developed by IBM. For more information, please read the SimG5 ReadMe.txt file, located in /Developer/Documentation/CHUD/. chudRemoteCtrl is a command line tool which allows you to remotely launch the performance analisys tools – that is: MONster and Shark – available in the CHUD package. It can be quite useful if you want to launch these tools on a remote computer (please note that you still need to put the GUI applications in the Remote Monitoring mode, available in the application menu) or in a shell script. For more information about chudRemoteCtrl, please read the dedicated man page. reggie se is the command line version of Reggie SE.

The Hardware preference pane The last but not the least is the Hardware preference pane. This is the kind of little applications that are really exclusive to the Mac OS X platform. I haven’t seen any equivalent tool on any other platform out there. What it provides is quite impressive: it lets you enable and disable the L2 and L3 caches of the processors. You can also disable a processor if you want to. And all this is done on the fly. Without a glitch. You can try for example to disable one of your processors while listening to an MPEG4 AAC audio file in iTunes. You’ll barely hear a little clipping in the sound. While Hardware can prove itself quite useful when you need to improve your code against cache usage, or to see how your product will behave on a slower single processor computer, I also found out another very nice effect of disabling a processor: not only is this an energy saver, but it also makes my dual processor PowerMac G4 far less noisy. Indeed, disabling one processor resulted in a decrease of about 1 to 2 celsius degrees of the heat sink, which made the fan in charge of cooling it far less speedy. And since you do this on-the-fly – without the need to reboot, for example – you can switch to single processing mode back and forth, at any time, without wasting time. Activating the ‘Nap’ feature of the processor is even more effective in cutting down the noise. The Hardware preference pane has its CLI counterpart: hwprefs which gives you the same abilities in terms of hardware manipulations but which can also give you some more details about the computer it is running on. % hwprefs -h ERROR: illegal action "-h" hwprefs v1.1.0 - (C)2003 Apple Computer

Chapter 2 : Performance and Profiling Tools

65

Architecture and Performance Group usage: hwprefs [options] parameter hwprefs [options] parameter=value OPTIONS -v -h

verbose mode display this help message

PROCESSOR COUNT cpu_count {1, 2}

number of processors used by the system

POWER SAVING cpu_nap {true, false}

processor nap

HARDWARE PREFETCH (PPC970) cpu_hwprefetch {4, 8}

INFO AND STATUS (READ ONLY) os_class os_type machine_type memory_size cpu_type cpu_freq cpu_bus_freq memctl_type ioctl_type

prefetch engines used by hardware prefetcher (any remaining used by DST instructions)

displays OS class {Cheetah, Puma, Jaguar, Smeagol, Panther} displays operating system type displays machine type displays system memory displays processor type and version displays processor clock frequency displays processor bus frequency displays memory controller type displays io controller type

Terminal Session #displays the code name of the Mac OS X currently used % hwprefs os class Panther #displays the type of CPU used and its version % hwprefs cpu type 7455 v2.1 #displays the processor frequency % hwprefs cpu freq 1000 MHz #displays the number of processors available %hwprefs cpu count 2 #changes the number of processors from two to one %hwprefs cpu count=1 1

66

Project:Ω — Panther for Developers

Figure 2.31: Hardware lets you disable memory caches or processors on-the-fly

the CHUD framework The CHUD package also provides a framework (available from /System/Library/Frameworks/CHUD.framework) which can be used in order to integrate some of the CHUD functions into third party applications or products. You can find the HeaderDoc documentation in the /Developer/Documentation/CHUD/CHUDFramework folder.

Useful URLs The main “performance” page for developers: http://developer.apple.com/performance/ Where to get the latest CHUD tools and other performance tools: http://developer.apple.com/tools/performance/ A small guide from Apple which tells you what you need to know to improve the performance of your products: http://developer.apple.com/performance/appperformance.html The starting point for Velocity Engine (a.k.a. Altivec) documentation and tools: http://developer.apple.com/hardware/ve/index.html

Chapter 2 : Performance and Profiling Tools

67

68

Project:Ω — Panther for Developers

Chapter 3

Major New APIs We will deal, in this section, with some of the brand new (or updated) APIs of Panther. This includes the new Web Kit, the new Search Kit and the AddressBook framework, which has been quite improved – as you may have noticed if you’ve been using the Address Book application. As we have already noticed it, Mac OS X 10.3 introduced major enhancements for the end-user but, most of all, it has laid several new major APIs, tools and technologies as the foundation for an ever evolving operating system. As a matter of fact, the more I got familiar with Mac OS X and understood the usability of its APIs and technologies, the more I started to believe that Apple has always made right choice – each and every time it had to decide which feature to add in the OS or whether or not include a technology in it. I am now convinced that every feature is part of a whole, of a long term development project – which, obviously, we don’t know anything about. For example, before the announce of Mac OS X 10.2, I was wondering for a long time why Apple was giving away so many sample code about applying various weird textures – such as text or QuickTime textures – to OpenGL objects. The meaning of all this appeared very clearly when Apple introduced Quartz Extreme. We could dig and find many other examples. One of the most relevant of these examples would be Apple’s web browser, as we will see in the next section.

The Web Kit Historical facts Steve Jobs revealed Safari, Apple’s web browser, during his Keynote on the 7th of January 2003. At the same time, Apple released the first beta of what would become the best, fastest and most compatible web browser of the Macintosh platform. Since the very first beta version of Safari on the 1/7/2003 and the release of the 1.0 version (6/23/2003), Safari is now the default browser on Mac OS X 10.3 and Microsoft Internet Explorer, is now a discontinued product. Safari is one great accomplishment made by Apple. I have heard that it took them two years from the decision to the official first version. It is quite a long time if you remember that two years ago, Mac OS X was at its 10.1 version, and that many of the foundations of the current version weren’t available yet. While it seemed that releasing a web browser that would render almost every ”real life” web site correctly would be quite a challenge, not only did Apple reach that goal, but Safari also performed better than any other browser available on Mac OS X (its main competitor was the Mac version†of Internet Explorer, but it also behaves almost as fast as the Windows version). Then, Microsoft officially announced that it couldn’t compete against Safari and froze the development of IE for Mac OS X. While the ins and outs of this decision are completely unknown and the situation kind of ironical, the huge success of Safari was totally deserved.

But this is not the end of the story. Safari was one of the long term development projects I was mentioning previously. Safari is not just a web browser. It is a web browser built upon a very powerful and highly efficient framework called Web Kit. Currently, several Panther applications already use it – Mail for the emails written in HTML, Help Viewer and Xcode for displaying the HTML help files, Sherlock (and of course Safari) for the web rendering. The good news is that Web Kit is public and available to any developer. So, as a developer, you can take advantage of all the great job done by Apple and hopefully create amazing new applications.

Introducing the Web Kit As we mentioned previously, Web Kit is a set of frameworks and SDK which will help you display and navigate through HTML files and – what is far more impressive – display and navigate on the Web. What I actually mean by the Web is the entire content of a “real life” web site: obviously, you will display the content of the HTML files rendered through CSS style sheets. But Web Kit allows you to go a lot further and benefit from its integrated Java applets, QuickTime plug-ins, JavaScript, SSL transport, automatic – or, at if you want really want it, manual – cookie and cache management, and so on. While the Web Kit framework contains code from various projects, it is easier to divide into its two main parts: the WebCore and the JavaScriptCore. WebCore is basically a wrapper built around the KTHML rendering engine – yes, the very same engine from the KDE project (www.kde.org) which empowers the Konqueror (www.konqueror.org) web browser – while the JavaScriptCore is a wrapper around the same project’s KJS. KHTML and KJS being GPL projects, Apple has tightly worked with the Konqueror team to improve the performance and compatibility of these engines and – since there’s little luck that you’re not using Safari yet – as you have noticed, the result is impressive.

Please Note While these projects are free projects available under the GPL license, you may have half a mind to download the sources and use them directly. Apple strongly advices you against doing such a thing because, first, they provide high level functions which will make your life a lot easier, second, the WebCore and JavaScriptCore are not public frameworks and hence the headers may change and break your application. If you really want to play with the sources, feel free to contribute and help improve the code!

The other good news is that the Web Kit framework is available by default on Mac OS X 10.3 but also on Mac OS X 10.2 provided that Safari 1.0 (or better) has been installed. The Determining Web Kit Availability documentation (/Documentation/Cocoa/Conceptual/DisplayWebContent/ Tasks/WebKitAvail.html) gives you detailed examples about how to determine the availability of Web Kit on the host computer and how to conditionally load the resulting dependent code.

70

Project:Ω — Panther for Developers

 Wrapping up : supported technologies · · · · · · · · · · · · ·

full support of HTML 4 full support of XML full support of CSS 1 and CSS 2 (CSS 3 implementation started) DOM level 1 and level 2 Cookies Authentication JavaScript 1.4 (ECMAScript 262 ed3) Plug-ins (Netscape style plug-ins, system wide) Java 1.4.1 applets SSL and TLS Proxies Unicode more, more, more

URL Loading API What you need to know before going any further is the global network layers introduced by the Web Kit. The Web Kit APIs are on top of the stack, and use extensively a new API called Foundation URL Loading API (see Figure 3.1). Foundation URL Loading API is a rather high level API which provides everything you need to load URLs, manage content caching and cookies, authentication and – the last but not the least – create your own custom protocols. Of course, it already supports the most common protocols of the Internet: · File Transfer Protocol (ftp://) · Hypertext Transfert Protocol (http://) · Secure Hypertext Transfer Protocol (https://) · Local file URLs (file:///) The URL Loading API is built on top of the CFNetwork one, which in turn, is built on top of the BSD Sockets. All these APIs are as fast as Apple made them, and since optimization seems to be a major concern in Mac OS X, using them ensures you to get the best performance available on the platform and benefit from the future optimizations the developer teams in Cupertino may come up with. This framework is used by several applications provided by Apple like SoftwareUpdate.

Useful URLs The URLLoadingSystem documentation: developer.apple.com/Documentation/Cocoa/Conceptual/URLLoadingSystem/index.html The URLLoadingSystem overview: /Documentation/Cocoa/Conceptual/URLLoadingSystem/Concepts/URLOverview.html

Web Kit Web Kit is built on top of the URL Loading API. Web Kit is mainly a Cocoa Objective-C API but it also has a C version which you can use for your Carbon development. You will find several examples of fully working Web Kit applications, in both Objective-C and C/C++ in the /Developer/Examples/WebKit folder. Carbon developers can also read the Accessing the Web Kit from Carbon Applications document, available from /Developer/Documentation/Cocoa/Conceptual/DisplayWebContent/Tasks/CarbonApps.html.

Chapter 3 : The Web Kit

71

We have already seen how powerful the Web Kit can be when we built the code-less browser in the previous chapter. The Displaying Web Content conceptual documentation (developer.apple.com/ Cocoa/Conceptual/DisplayWebContent/) provides you with some good reasons to use it, if you were still not convinced of the great benefits you can get from it. Safari

Mail

YourApp

WebKit WebCore (KHTML)

JavaScriptCore (KJS)

Foundation URL CFNetwork BSD Sockets

Figure 3.1: The global network technology layers The usage of the Web Kit is rather straightforward: for basic web browsing you barely need to do something: just setup an instance of webView and then load an URL with a single line Objective-C code like:

//to load an URL stored in an NSString [[webView mainFrame] loadRequest: [NSURLRequest requestWithURL:[NSURL URLWithString:myURL]]];

With this very basic line of code, you will benefit of everything you can think of regarding a web site: CSS, JavaScript, QuickTime, Flash, Java Applets and, of course, the user has the ability to click on the links and navigate among the pages. Basically, you use the Web Kit through the WebView class to and the mainFrame of which you send a load message. Whether your HTML page is a single regular page or a multi-framed one, the WebView will create one or several WebFrames. You can then interact with the mainFrame or the other frames of your choice. While the Web Kit comes with many default options which are really great and let you “just-browse” without the need of any configuration, you may be happy to know that you can also make it behave exactly the way you want it to. First of all, the WebView inherits from the NSView class, which then allows you many customizations. Then, since Web Kit is built on top of the Foundation URL Loading API, you can define your own cookie, cache, authentication policies. And finally, several delegate methods are available inside Web Kit in order to let you do the things the way you want them to. Here are the names of the protocols implemented and a brief description of what you can do with them: WebFrameLoadDelegate The delegate methods implemented in this protocol notify you when the state of the frame is changing – loading started, loading finished, frame being closed, etc. – when it has received some data – such as the title and the icon for each frame – and error and redirection messages. WebPolicyDelegate This protocol lets you edit the policy decisions made when handling URLs or data. You can, for example, manually handle clicks, and prevent the user from downloading a .exe file – or at least, ask him for confirmation before you actually start the transfer.

72

Project:Ω — Panther for Developers

WebResourceLoadDelegate This protocol is the equivalent of the WebFrameLoadDelegate but for single resources contained in the pages : you can manage the loading activity of each resource and get notified on the progress of loading individual resources. WebUIDelegate This protocol is probably the most important one if your goal is to customize the behavior of your web/HTML browser. It manages the window attributes – such as its ability of being resized, show and hide the toolbar – and all the UI-related activity like opening JavaScript panels, handle mouse events, etc.

Useful URLs Displaying Web Content conceptual documentation: developer.apple.com/Documentation/Cocoa/Conceptual/DisplayWebContent/ The Web Kit Objective-C Reference: developer.apple.com/Documentation/Cocoa/Reference/WebKit/ObjC_classic/ The Web Kit C Reference: developer.apple.com/Documentation/Carbon/Reference/Web_Kit_C/

The Search Kit Introducing Search Kit Basically, Search Kit is an advanced C framework which allows you to index and search text in files. It is the Mac OS X version of what was formerly code-named V-Twin (not so many people remember its official name which was AIAT : the Apple Information Access Toolkit). At last, V-Twin is available and this is great news for many developers. I remember having heard the complaints of many developers about its unavailability in previous releases of Mac OS X. I am pretty sure that when you will find out that Search Kit is the technology which provides the impressively fast search-by-content functions of the Finder, Mail, Apple Help or Xcode, you’ll be quickly willing to learn more about it in order to include some impressive functionalities into your own applications. Search Kit is a streamlined C API which uses CF types. It’s almost language independent. This means that you can index text from most human languages – even if you speak only US or UK English, it’s good to know that your users from all around the planet will be able to benefit from your new search feature. Using Search Kit is a two-step operation: you first have to create an index (or several, depending on your needs). Indexing the documents is important in order to: 1. make the search fast 2. allow statistical information to be gathered 3. store the indexes in files (making it persistent) or in memory (if you have huge performance needs) 4. allow you to perform searches on files which may not be available on the computer anymore (for example, files archived on an DVD-R) Then create queries in order to perform your searches. Four types of queries are available in the Search Kit and all have their own usefulness: 1. Ranked search is used for natural language queries – as the Apple Help does. 2. Boolean search is used for boolean queries – ‘&’, ‘|’ ‘(’, ‘)’ and ‘!’ can be used in the search field. 3. Required search is similar to queries you can send in web search engines – you can type ‘+’ for the required terms and ‘−’ for the excluded ones in the search field. 4. Prefixed search is an ‘as you type’ mode similar to the queries you type in the search field of Mail or Xcode – useful for partially typed or abbreviated queries.

Chapter 3 : The Search Kit

73

Principles of indexing Creating an index is not a simple task. Imagine all you have to do in order to create an index which will allow you to do content searching, and all the other queries allowed by the Search Kit: · You have to do some basic language work on the text in order to split it into words. While is a pretty easy for Indo-European languages it may become an amazingly complex work on some other languages – like the Japanese, which doesn’t include space characters between words. · You have to do a statistical analysis in order to find the relevant words of the files. You will also have to do such an analysis on the user provided query before performing your own one. · Then you have to be able to analyze many different types of files – text, RTF, Word, PDF, HTML, and why not email messages or Address Book entries, like the Search Kit do. As you can see, a whole engineering team is required in order to build an index. But you also need mathematicians and a linguist for each language you want to index. This makes quite an expensive and unrealistic project. Fortunately, Apple has made all the hard work and provides all the benefits of this work to the developer, in a simple to use, easy to implement framework. Creating an index is rather easy, since Search Kit provides you two very straightforward functions: · SKIndexCreateWithURL Creates an index in a file whose location is specified with a CFURL. · SKIndexCreateWithMutableData Creates an index stored in a CFMutableData object. Managing the content of an index is as easy: · SKIndexAddDocumentWithText Adds a document and its text to an index. · SKIndexAddDocument Adds a document to an index. · SKIndexRemoveDocument Removes a document and its children, if any, from an index. · SKIndexRenameDocument Changes the name of a document in an index. One last thing about indexes – there are three kinds of them: · Inverted: Specifies an inverted index, mapping terms to documents. · Vector: Specifies a vector index, mapping documents to terms. · Inverted Vector: Specifies an index type with all the capabilities of an inverted and a vector index. Obviously – and as recommended by Apple – the inverted index is the index type you should use in most cases, since queries are usually terms and the user wants to find the corresponding documents. For additional information about creating and managing indexes and performing queries, please refer to the Search Kit documentation.

Useful URLs Search Kit Reference: developer.apple.com/documentation/UserExperience/Reference/SearchKit/ Introduction to Search Fields: developer.apple.com/documentation/Cocoa/Conceptual/SearchFields/

74

Project:Ω — Panther for Developers

The Address Book Framework I guess everybody knows the Address Book application which lays in the Applications folder of since Mac OS X 10.2 – you probably already use it to store your contacts, and access them in Mail or synchronize your bluetooth cell phone. The Address Book is part of the big Digital Hub plan and Apple has put a lot of efforts into making it a ”centralized database for contact and other personal information”. Currently, among the applications which ship with Mac OS X 10.3, Mail, iChat, Address Book, Safari, Sherlock, and iCal already use this database. But do you know that you can, as a developer, access these contacts, manage individual contacts or groups, and so on? In Panther, Apple has improved the Address Book – both the database and the application – and added many new and requested features. The Address Book has also been greatly improved. Let’s review the most important changes in the database and have a small overview of the APIs.

The Address Book Framework First of all, Address Book is thread safe – which means that you don’t have to manage your threads in order to prevent them from accessing simultaneously the database – and is also concurrent accesses aware – which means that if two threads or two processes try to simultaneously change the data of the same entry, the database will remain consistent and coherent. One other great feature of this database is that it has an extensible property set. Hence you are not limited in using the entries provided by Apple and create those you need.

Basically, the Address Book framework is accessible from Objective-C and C/C++ but also from AppleScript. The Objective-C API provides you several classes – the C API is strictly equivalent to the Objective-C one and the AppleScript dictionary offers almost the same possibilities – among which you will find: ABAddressBook provides you all the methods you need to manage the user’s Address Book database: adding removing records – both contacts and groups – searching, saving, etc. ABRecord is the abstract superclass from which ABPerson and ABGroup will inherit ABPerson is a subclass of ABRecord. You will use an instance of this class to retrieve all the information you need for a contact – name, company, email addresses, phone numbers. . . ABGroup is a subclass of ABRecord. You will mainly use the instances of this class in order to get a list of the members of a given group or to manage the contacts/groups it contains. ABSearchElement is used to specify a search query for records in the Address Book database.

Please Note The function/variable names given here are taken from the Objective-C API. The Address Book framework has two sets of files, one for Objective-C files, and one for standard C. They have the same title but the C files have a ’C ’ suffix like in ABAddressBook.h vs. ABAddressBookC.h

In Mac OS X 10.3, the ABPerson features new properties, such as the kABOtherDatesProperty – which allows you to store other dates than the classic birthday – the kABRelatedNamesProperty –

Chapter 3 : The Address Book Framework

75

which helps linking people to other relatives or coworkers – and the kABDepartmentProperty which lets you specify the name of the department in which the contact works. The kABShowAsCompany and kABShowAsPerson are new and their usage obvious. The notifications of the Address Book have also been improved since the kABDatabaseChangedNotification and kABDatabaseChangedExternallyNotification now return a dictionary containing the records which have been changed/added/removed.

Please Note: the user’s country code and Address Book Many developers often wonder how they can find out the country in which the user lives in order to format an address, or to display/format some information relatively to the rules of that specific country. Well, few of them knows that the answer is hidden in the Address Book framework which provides two very useful functions: defaultCountryCode which returns the default country code specified by the user formattedAddressFromDictionary which allows to create a postal address formated for a given country

AppleScript Support in the Address Book application AppleScript developers will be happy to learn that there has been major improvements in the AppleScript support of the Address Book. All the new properties introduced in Panther are available, the Me card can now be edited and the company flag, user image, vcard export are available. Scripts stored in the /Library/AddressBookScripts and ~{}/Library/AddressBookScripts will automatically be added to an AppleScript menu which appears in the Address Book application. This is one very convenient way to add new features to the Address Book application or to customize it for your specific need.

More developer perspectives The People Picker UI element You have already used the People Picker UI element in the section 2.3.2 when you created a simple ‘codeless’ Address Book application. Figure 2.3.2 shows how easily you can configure it with InterfaceBuilder. For more information about the methods and notifications available for this UI element, please take a look to the ABPeoplePickerView.h in the Address Book framework (and ABPeoplePickerC.h for the C API – which isn’t named after the Objective-C file here).

The Action plug-ins The last thing about the Address Book is the new API Apple has released in order to let you extend the possibilities of the Address Book application: Action Plugins. These plug-ins allow you to add new capabilities to the little roll-over menu which appears when the mouse pointer is above a given property – for example, the one which lets you send an SMS when you click on the phone number of a contact while being connected to a bluetooth cell phone. Action plug-ins can be written in Objective-C, C/C++ and AppleScript. All the functions and variables you need are available in the ABActions.h and ABActionsC.h header files of the Address Book framework. In order to take advantage of these plug-ins, you will have to store them in the “/Library/Address Book Plug-ins” or “~/Library/Address Book Plug-ins” folders.

76

Project:Ω — Panther for Developers

Figure 3.2: Configuring the People Picker with the Inspector of InterfaceBuilder

Useful URLs Address Book Introduction: developer.apple.com/documentation/UserExperience/Conceptual/AddressBook/ Address Book Reference: file:///Developer/Documentation/UserExperience/Conceptual/AddressBook/

Appendix : The Address Book Framework

77

78

Project:Ω — Panther for Developers

Appendix A

Categorized CLI developer tools Documentation compileHelp – utility to merge contextual help rtf snippets into one resource headerdoc2html – header documentation processor pbhelpindexer – indexes the installed HTML documentation pod tools – pod documentation processing tools

Source Control Management agvtool – Apple-generic versioning tool for PB/Xcode projects CVS tools – Concurrent Versions System tools cvs-wrap and cvs-unwrap – wraps a directory into a tgz file and vice-versa RCS tools – Revision Control System manages multiple revisions of files.

Parser and Lexical Analyzer generators bison – GNU Project parser generator (yacc replacement) flex and flex++ – fast lexical analyzer generator lex and lex++ – symlinks to flex and flex++ yacc – a parser generator

Building jam – build system libtool – create libraries mkdep – construct Makefile dependency list pbxbuild – used to build ProjectBuilder projects (see xcodebuid) pbprojectdump – output a more nested version of the project structure pbutil – list groups and files in a project and more ranlib – add or update the table of contents of archive libraries redo prebinding – redo the prebinding of an executable or dynamic library update prebinding – update prebinding information for newly changed files xcodebuild – build Xcode projects

Resource manipulation and software localization DeRez and Rez – decompile/compile resources genstrings – generate string table from source code ResMerger – Merges resources into resource files RezWack and UnRezWack – ressource management for QT on Windows

Scripting awk – pattern-directed scanning and processing language osascript – execute AppleScripts and other OSA language scripts osacompile – compile AppleScripts and other OSA language scripts Perl tools – Practical Extraction and Report Language tools perlcc – generate executables from Perl programs pod tools – pod documentation processing tools ruby – interpreted object-oriented scripting language sed – stream editor tcl – Tool Command Language

File manipulation CpMac – copy files preserving metadata and forks GetFileInfo – get attributes of HFS+ files MvMac – move files while preserving metadata and forks pbxcp – copy files with many options and preserve metadata SetFile – set attributes of HFS+ files tops – perform in-place substitutions on code

Performance and Profiling acid – TT6E instruction trace analyzer amber – create TT6, TT6E and FULL instruction traces chudRemoteCtrl – launch remotely MONster and Shark fs usage – report system calls and page faults in real-time hwprefs – the command line version of the Hardware preference pane heap – list all the malloc-allocated buffers in the process’ heap gprof – display call graph profile data ktrace and kdump – trace kernel process and display the generated data latency – monitor scheduling and interrupt latency leaks – search a process’ memory for unreferenced malloc buffers malloc history – show the malloc allocations the process has performed reggie se – the command line version of the Reggie SE application sample – profile a process during a time interval sc usage – show system call usage statistics simg4 and simg5 – PowerPC 7400 (G4) and PowerPC 970 (G5) simulator top – display and update sorted information about processes vmmap – display the virtual memory regions allocated in a process vm stat – show Mach virtual memory statistics

Software installation installer – system software and package installer tool mkbom – create a bill-of-materials file pbxhmapdump – dumps to standard output the contents of the .hmap file softwareupdate – system software update tool

80

Project:Ω — Panther for Developers

Appendix B

Networking APIs in Mac OS X 10.3

 Wrapping up : Networking APIs in Mac OS X 10.3 Here is a summary of the state of the various networking APIs available in Mac OS X: · · · · · · ·

Foundation URL Loading API: new, supported Foundation NSURLHandle: supported but superseded by the URL Loading APIs Foundation NSURL: supported, internally updated to newer APIs NSStream: supported CFStream: supported CFNetwork: supported URL Access Manager: available but development is frozen. Use the CFNetwork and URL Loading APIs instead. · BSD Sockets: supported · OpenTransport: deprecated · InternetConfig: deprecated. Use Launch Services and SystemConfig

Index ¬, 18 #, 14 %, 15 LATEX, 2 LATEX packages, 2 TEXShop , 2 a2p, 56 ABI, 11 acid, 65 Action plug-ins, 77 Action Plugins, 77 Address Book, 75 Address Book framework, 77 AddressBook, 69 AddressBook Palette, 42 agvtool, 50 AIAT, 73 Altivec, 68 amber, 65 Apple Information Access Toolkit, 73 AppleScript (Xcode support of), 38 application binary interface, 11 apt-get, 21 ar, 55 auto-completion, 27 autotools, 13 awk, 56 BigTop, 62 bill of materials, 56 bison, 56 bom, 56 bsdmake, 14 BuildStrings, 50 CacheBasher, 64 check out (SCM systems), 36 CHUD (tools), 62 chudRemoteCtrl, 65 ci, 55 CLI, 9 CLI developer tools, 50 co, 55 Cocoa Bindings, 43 code completion, 27 code indexing, 27 Code Sense, 27 CodeWarrior importer, 38 CodeWarrior inline assembly, 12 command line tool, 9 commit (SCM systems), 36 compileHelp, 54 Concurrent Versions System, 36 Controller Palette, 42

82

country code, 77 CpMac, 50 CVS, 36 cvswrappers, 50 DarwinPorts, 2, 17 Data Formatters, 34 deployment target (SDK), 37 DeRez, 51 Developer Tools, 25 distcc, 31 Distributed Builds, 31 dpkg, 21 dselect, 21 Fink, 2, 17, 21 fink, 21 FinkCommander, 23 Fix and Continue, 33 flex, 56 flex++, 56 Foundation URL Loading API, 71 FreeBSD ports, 17 gcc, 11, 63 gcc 3.3, 11 gcc optimization flags, 12 gcc select, 15 genstrings, 54 GetFileInfo, 51 GNU autotools, 13 GNU RCS, 55 gnumake, 14 Hardware, 65 HeaderDoc, 67 headerdoc2html, 54 human interface guidelines, 40 hwprefs, 66 iTEXMac, 2 Inspector, 33 installer, 56 Intaller, 56 J2EE, 25 jam, 53 JavaScriptCore, 70 JBoss, 25 key bindings, 27 keyboard shortcuts, 27 lex, 56 lex++, 56 libtool, 54

Project:Ω — Panther for Developers

lsbom, 56 Mac OS X for Unix Users, 10 MANPATH, 18 MergePef, 51 Mini Controls, 41 mkbom, 56 mkdep, 54 MONster, 62 MvMac, 51 native target, 40 Nib, 40 Nib file format, 41 optimization flags, 12 osacompile, 54 osalang, 55 osascript, 55 PackageMaker, 57 Parallel Build, 30 PATH, 18 pbhelpindexer, 51 pbhelpindexloader, 53 pbprojectdump, 51 pbutil, 52 pbxcp, 52 pbxhmapdump, 53 PCH, 12 People Picker UI element, 77 Perforce, 36 perl, 56 Perl scripts (automating Xcode with), 38 perlcc, 56 perlpod, 56 plutil, 55 PMC Index, 63 port (CLI tool), 18 ports, 17 prebinding, 55 precompiled headers, 12 predictive compilation, 29 python, 56 Python scripts (automating Xcode with), 38 ranlib, 55 RCS, 55 rcs, 55 rcsclean, 55 rcsdiff, 55 rcsfile, 55 rcsfreeze, 55 rcsintro, 55 rcsmerge, 55 redo prebinding, 55 Reggie SE, 65 reggie se, 65

Appendix B : INDEX

Remote Monitoring, 65 repository (SCM systems), 36 ResMerger, 53 Revision Control System, 55 Rez, 51 RezWack, 53 rlog, 55 ruby, 56 s2p, 56 Saturn, 63 Script menu (Xcode), 39 SDK, 37 sdp, 53 Search Fields, 75 Search Kit, 69, 73, 74 SearchKit, 28 sed, 56 SetFile, 53 Shark, 64 shell script (automating Xcode with), 38 shortcuts, 27 simg4, 65 simg5, 65 Skidmarks GT, 64 SmartGroups, 27 SoftwareUpdate, 56 softwareupdate, 56 source code management, 36 SpindownHD, 65 SplitForks, 53 Subversion (SCM), 36 systemsetup, 57 tcl, 56 TeTEX, 2 thread safe, 76 tops, 55 uninstall-devtools.pl, 53 UNIX Porting Guide, 10, 16 UnRezWack, 53 update prebinding , 55 upgrading targets to native, 40 V-Twin, 73 Velocity Engine, 68 Web Kit, 69, 70 WebCore, 70 WebFrames, 72 WebKit, 28, 42 WebView, 42, 72 WSMakeStubs, 53 Xcode, 25 Xcode CD, 25, 58 xcodebuild, 55

83

yacc, 56

84

Project:Ω — Panther for Developers

www.projectomega.org