OS X Developer Tools
OS X Overview
I bought my first Mac in Fall 2001, a small 600 MHz iBook. I had used OS 8/9 before then, so I had experience with the Mac platform, but I didn't start developing Mac software until I got my iBook. It's funny to think about, but I think the major reason I waited until then was that OS X came with free compilers and developer tools. With older Mac OS's, you had to buy commercial tools, and development was difficult because of the different way Mac OS handled multitasking and memory protection. It was rather baroque compared to the development methods used for OS X apps.
The main reason I bought that iBook was because OS X had a unix core and a nice-looking UI. I was writing lots of web applications then, and I wanted a laptop that would let me develop portable Unix apps, but also look really good when I was surfing the web, watching movies, and doing other non-hacking things. After a while, I started looking at how Mac apps themselves were developed, and I started playing with the Developer Tools. I still remember loading Project Builder and Interface Builder on my iBook the first time, it was light years beyond anything Linux or BSD could offer at the time.
As OS X has matured, developers have gotten ever greater access to the power of their machines. The power that a developer can wield with today's OS X is intense. You can do accelerated graphics without a lot of fuss, design digital audio filters or programs that handle 100 channel sound, generate complex movies programmatically, create distributed programs, and use many other state-of-the-art technologies. Frameworks like CoreAudio, CoreImage, Quartz, QuickTime, and CoreMIDI let developers focus on adding novel features to their applications, without needing to concern themselves with low-level glue and library code. That's the thing that makes OS X apps a pleasure to write. Apple is always enhancing their development environment so you have to write less code to get common features. Apps crash less often, because the bulk of their code uses common well-tested frameworks instead of random self-developed code. This also lets developers focus on their area of expertise instead of reading manuals about placing UI elements on a window or adjusting their audio code for the sample rate of different inputs.
Most OS X apps are written in ObjC, although some folks are starting to write them in Java using the JNI bridge that Apple provides. I've only used ObjC so far, but am thinking about using Java models and ObjC controllers for a future project of mine.
Developer Tools
Much has been written about Apple's core developer tools. Xcode and Interface Builder are the ones you'll hear about the most, since they are the tools you use to actually write and build the code for your apps. That said, there's a lot more developer tools provided by Apple that are invaluable. I'm going to talk a bit about the ones you might not have heard of yet.
Xcode snapshot
Interface Builder snapshot
The Semi-Forgotten Developer Tools
Now, let's talk about those tools that you might not have tried yet. I'm going to discuss ones that I find very useful, although there are many more inside /Developer/Applications, if you've installed the Xcode developer pack. First, let's do a high level overview of the tools, and then look at them one by one.
- Shark - GUI profiler and disassembler
- OpenGL Driver Monitor - See detailed information about your video card's OpenGL drivers, and grab remote statistics from another machine's OpenGL card
- OpenGL Profiler - Watch running applications and gather statistics on their OpenGL frame rate, or grab traces of OpenGL calls being made for further debugging
- Pixie - A Quartz magnifying glass that zooms in on your screen and allows pixel-by-pixel debugging of your graphics display code
Shark
Shark is my favorite OS X developer tool. It is best described as a profiler hopped up on steroids, with many more performance visualization options compared to tradtional profilers. It allows low level and high level profiling of your app, and is a nice complement to Xcode's debugger. Apple does a much better job of describing Shark and its capabilities than I can, so if you're interested, check out their overview of Shark's features and a profiling run on a real-world OS X app, Celestia.
On top of performance visualizations like time-per-function, it has a great instruction browser that lets you inspect disassembled code. I used it to help me with some Altivec code I was trying out. When you click on the instruction, a window pops up, telling you its arguments and including a brief discussion of what it does and what it should be used for. It works on any java or C/C++/ObjC code. I've used it as a crude non-intrusive debugger if I want to see what a busy app is doing or why a perl or ruby interpreter is in an infinite loop.
Really, just go and read the Apple link for Shark that I mentioned above. It is difficult to describe everything Shark can do, and the screen captures show a lot of its features. I've worked with free and commercial profilers on unix platforms before, and this is the best one I've seen. You don't get tools like that on win32 for free. it.
OpenGL Driver Monitor
I don't do any video driver work, but the OpenGL Driver Monitor is really useful for getting detailed information on your video card's capabilities. It also lets you grab realtime statistics on low level OpenGL functions like the number of moves from the frame buffer to the screen, how many pbuffers are in use, how full your texture memory is, etc. This will show you what operations are getting bogged down, and makes a nice complement for the OpenGL Profiler, which you'd use to see what OpenGL calls are being thrown at your card. Combining the two lets you diagnose and fix bottlenecks in your OpenGL code.
OpenGL Profiler
OpenGL Profiler lets you see high level frame rates for your OpenGL code and capture traces. You can attach to any application and see what OpenGL api calls are happening. Want to see how your favorite game draws its scenes? Attach the profiler to the process, play the game until you hit a point you want to look at, and click a button in the profiler to start tracing OpenGL calls. You then see all the calls made during your trace period. Very useful! The above capture from OpenGL Profiler shows a JOGL example app running the ubiquitous OpenGL gears demo.
Pixie
Pixie lets you zoom in on your graphics window and debug your graphics drawing code. I use it when I have to draw shapes with per-pixel accuracy and want to make sure i'm drawing them correctly. It is possible to grab a screen capture and zoom in, but Pixie works in realtime and lets you configure zoom factor, window size, etc.
Look at the full-size Pixie capture and you'll see how anti-aliased fonts are drawn on the screen. Tres cool!
Tiger Development Tools
There's not a lot I can say about Tiger's tools since I'm still under NDA, but suffice to say that they have been upgraded. There is a new Quartz-related tool that is a quantum leap for adding graphics to your applications, it will blow your mind when you see it. It's the sort of thing that developers dream about and joke that it would be nice to have, and Apple actually developed it. It's almost scary to contemplate what developer applications future major releases of OS X will contain. Panther was already a cut above win32, but Tiger just blows it away. Microsoft will never catch up in this race, because the Apple tools aren't just pretty, their features are truly innovative. Microsoft simply can't keep up with this pace of innovation, their organizational inertia is too big. Once Tiger is released, I'll talk more about its developer tools.
One more thing, if you're an AudioUnit developer, then you're going to just LOVE some of the new Tiger tools. They made my jaw drop when I first saw them. I wish I could give Apple's developer tools team a big group hug right now.