Programming

Confusing stuff: NSLog and SystemSoundID

In my first attemps with iPhone SDK programming – while working on Running Mate’s early proof of concepts – I tested the playing of short sound effects. That’s where I encountered this strange error:

    warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found). 
    warning: Unable to read symbols from "UIKit" (not yet mapped into memory).

As you can see, this error is entirely meaningless on its own – if this was true, none of apps would work. Which was not the case. This happened with 2.1 final SDK, where I last checked for this.

It turns out that problem was with this line:

NSLog(@"Play sound: %@", _soundID);

where _soundID is of type SystemSoundID. Commenting this line out resolved the problem.

My guess here is that SystemSoundID does not have description properly implemented. %@ should cover any object that accepts description message, so it’s not strange that a beginner would try to log it as given above. And would be mightily confused by the message in the console window, as I was.

I got out of this by commenting out lines of code, one by one, starting from the last one I added.

Hopefully someone else will find this and saves oneself some time and nerves.