August 2011

Xcode 4 Book Status Report: August 22

I cleaned up the modeling tools chapter enough to move it to the almost ready to layout category. I proofread some sections of the Interface Builder and debugging chapters so they’re closer to being in the ready to layout category.

Right now I’m working on the Instruments chapter, which is the largest remaining obstacle to finishing the book. The Instruments chapter has the following main topics:

  1. Setting up a trace.
  2. Running a trace.
  3. General material on interpreting the trace results that applies to most instruments.
  4. Instrument-specific results for the Leaks, Allocations, Time Profiler, OpenGL ES Analyzer, and Activity Monitor instruments.
  5. Creating custom instruments.

Topics 1 and 2 are cleaned up. This week I’m going to be busy cleaning up the rest of the Instruments chapter.

No comments | Trackback

New Xcode Project for SDL OpenGL Article

I added a link to the sidebar of my SDL OpenGL article that contains a version of the project updated for Xcode 4.1. The original project had several problems building on Xcode 4.1 that persisted after I modernized the project. The updated version of the project works on Xcode 4.1 and uses the Mac OS X 10.7 SDK. I have not tested the project on Xcode 4.0, but at a minimum, you must change the Base SDK to 10.6 to get the project to work on Xcode 4.0.

The original project is still there. I just added another version to make things easier for people using Xcode 4.1.

No comments | Trackback

Xcode 4 Book Status Report: August 15

Here’s how the cleanup of the material is coming along.

Ready to layout: projects, code editing, version control, command-line tools, and OpenGL tools chapters

Almost ready to layout: debugging and Interface Builder chapters

More cleanup to do: modeling tools, building projects, and Instruments chapters

No comments | Trackback

Installing Mac Compilers Without Using Xcode

Most programmers with a Mac install Xcode when they need a C/C++/Objective-C compiler because Xcode includes everything you need to write C, C++, and Objective C code on Mac OS X. Xcode is a large download and is excessive if all you want to do is install GCC, LLVM, or Clang on your Mac. Kenneth Reitz has placed a compiler installer on Github that lets you install GCC, LLVM, and Clang without downloading Xcode. You can learn more by clicking the following link:

os-x-gcc-installer

I have Xcode installed so I haven’t tested the installer, but I know some Mac-using programmers will be interested in this.

No comments | Trackback

Supplying a Method Name to an Objective-C Custom Instrument

One of Instruments’ most powerful features is the ability to create your own instruments. Apple supplies an Objective-C provider to DTrace, which Instruments is built on. In the Objective-C provider, you can tell a probe to fire when you enter or exit an Objective-C method. Supplying the method name can be tricky, especially if the method takes multiple arguments. This post shows you how to supply a method name to an Objective-C custom instrument.

Create a new instrument in Instruments by choosing Instrument > Build New Instrument. If you choose the Objective-C provider, the top of the probe looks like the following:

Objective C Probe

As you can see in the screenshot, you can supply a class and a method name to limit when the probe fires. Suppose you want the probe to fire when you enter an Objective-C method. You would enter the following for a method that takes no arguments:

-MethodName  (Instance method)
+MethodName  (Class method)

If the method takes one argument, place a colon after the method name.

-MethodName:

Things become more complicated if the method takes multiple arguments. You can’t have multiple colons in the method name text field because DTrace interprets colons as provider field separators. Use question marks instead of colons to separate the method’s arguments. Let’s look at an example. Suppose you have the following Objective-C method in your application:

- (BOOL)readFromFileWrapper:(NSFileWrapper*)appFileWrapper ofType:(NSString*)typeName error:(NSError**)outError

You would enter the following as the method name:

-readFromFileWrapper?ofType?error?

Notice how you enter the argument name, which is the text to the left of the colon, and a question mark for each argument.

No comments | Trackback
Powered by WordPress