Xcode Build and Analyze broken for simulator

I did not no tice this problem when I first upgraded to Xcode 3.2.4 and iOS 4.1 but it seems that the Build and Analyze function of Xcode is broken when the target is the Simulator. The problem is very easy to miss since it does not show as an error in the build log. If you are not paying attention you can end up thinking you have run the analyzer on your code without issues.

If however you keep a close eye on the build window or change the settings to show “All Messages” instead of “Issues Only” you will see some output complaining that “Analyzer skipped this file due to parse errors”

You can dig down further into the build logs which show a series of errors in various iPhoneSimulator4.1.sdk files:

In file included from /Developer/Platforms/iPhoneSimulator.platform/
error: expected function body after function declarator CFDataRef metadata)

This seems to be a known issue with the iOS 4.1 SDK when building for the simulator. The solution is simple enough - select a device as the target when using Build and Analyze. Hopefully this will get fixed with iOS 4.2.