Hey, you noticed in your new Xcode projects recently that CodeSense is only working for your code, not SDK frameworks? And haven’t been able to figure out why? Yeah, us too. Turns out the problem is turning on analysis — aka “RUN_CLANG_STATIC_ANALYZER” — in your base .xcconfig, as noted here on OpenRadar:
Summary:
For any project of mine in which RUN_CLANG_STATIC_ANALYZER is set to YES, CodeSense symbol lookup fails for non-explicitly-imported symbols (i.e. Foundation/UIKit classes and methods, etc.). Because the CodeSense index fails to build, code completion and option-double-click documentation searches also fail.
Ah, so that’s the trick! And why yes, commenting that line out of our base config file and clicking ‘Rebuild Code Sense’ in the project info has indeed given us our SDK class option-click back. How nice!
However, we really really don’t want to do without the analyzer, as it’s been pretty darn useful in identifying subtle oversights. And in the occasional case where it misidentifies leaks and the like, we’ve tended to adopt the attitude that “well, if the analyzer can’t figure out how this works, the chances are pretty good nobody tasked with maintaining this in future will be able to either”. And in our 20+ years at this programming thing, we have increasingly come to the conclusion that in virtually all cases the only metric worth evaluating code quality by — after “correctness of result”, of course — is not its efficiency, not its cleverness, not its elegance, but its maintainability.
So we’re now trying the workaround of enabling clang only in the debug configuration and leaving it off for the AdHoc/AppStore configurations, and so far that appears to indeed be working and providing us both CodeSense and analysis while developing. But if any of you have a better solution, please share!

0 Responses to “Tip: CodeSense FAIL”
Leave a Reply