Thursday, October 7, 2010

Xcode Analyzer Error: "Analyzer skipped this file due to parse errors"

Apple integrated the Clang Static Analyzer into Xcode a while back. It's a part of the LLVM project and it uses the clang C/C++/Objective-C compiler front-end to the LLVM compiler to perform static analysis. The static analyzer (or "clang checker") is really useful for finding common retain/release errors in Objective-C code. You run the analyzer by building your project using the Build and Analyze item under the Build menu.

When I recently went to run the static analyzer on one of my projects using the recently released iOS 4.1 SDK, I got a series of the following types of errors:
Analyzer skipped this file due to parse errors

 '/var/folders/p9/p9X0YndXGHyxgsdRDDYre++++TI/-Caches-/com.apple.Xcode.501/SharedPrecompiledHeaders/PrecompiledHeaders-cbytywsinixhviaxvbooriusnxyo/PrecompiledHeaders.pch' file not found
I found the following workaround for the problem in the Apple developer forums (registration required).

On the Project menu, select Edit Active Target "MyProject" to bring up the Target Info dialog. Edit the Other C Flags setting and add -D__IPHONE_OS_VERSION_MIN_REQUIRED=030000, where 030000 corresponds to the iOS Deployment Target setting:
  • 3.0 -> 030000
  • 3.1 -> 030100
  • 3.2 -> 030200
  • 4.0 -> 040000
  • 4.1 -> 040100
Then the analyzer should be able to run successfully.

2 comments:

Enric said...

Thanks, worked perfectly.

Don McCaughey said...

Cool, glad it helped!