Xcode 3.2:构建和构建分析从来没有发现任何问题
我之前已经从命令行使用过 Clang 静态分析器。我想通过 Build & 尝试 Xcode 的内置版本。分析。尽管我专门准备了具有非常明显问题的代码,但我从未得到任何负面结果,Clang 总是能够指出:
// over-releasing an object:
[label release];
[label release];
// uninitialized vars, allocating but not freeing an object
NSString* str;
int number;
CCLabel* newLabel = [[CCLabel alloc] initWithString:str fontName:str fontSize:number];
[newLabel setPosition:CGPointZero];
结果总是相同的:绿色复选框,没有问题。 我读到 C++ 代码可能会导致问题。我正在使用包含 box2d 的 cocos2d 运行它。这可能是一个原因吗?有人从“构建与构建”中得到结果吗?用cocos2d引擎分析?还能是什么?
我还尝试启用静态分析器构建设置,然后构建,但结果是相同的。我重新启动了 Xcode,清理了所有目标并清空了 Xcode 缓存,但无济于事。
更新:我的问题可能是由于将 cocos2d 添加为我的项目的跨项目引用而引起的。单独分析 cocos2d 项目本身会显示一些分析结果。
此外,我发现我从发布构建配置中获得分析器结果,而不是从调试构建中获得分析器结果。
I've used the Clang Static Analyzer from the command line before. I wanted to try Xcode's built-in version via Build & Analyze. I never get any negative results even though i specially prepared my code with very obvious issues Clang was always able to point out:
// over-releasing an object:
[label release];
[label release];
// uninitialized vars, allocating but not freeing an object
NSString* str;
int number;
CCLabel* newLabel = [[CCLabel alloc] initWithString:str fontName:str fontSize:number];
[newLabel setPosition:CGPointZero];
The result is always the same: a green checkbox, no issues.
I read that C++ code can cause issues. I'm running this with cocos2d that includes box2d. Could this be a cause? Did anyone get results from Build & Analyze with the cocos2d engine? What else could it be?
I also tried enabling the Static Analyzer Build Settings and then Build but the result was the same. I have restarted Xcode, cleaned all targets and emptied Xcode caches to no avail.
UPDATE: my issue could be caused by having added cocos2d as a cross-project reference to my project. Analyzing the cocos2d project itself seperately reveals some analyzer results.
In addition i found out that i get Analyzer results from my RELEASE build configurations but not from DEBUG builds.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我正在使用 Cocos2d 和 Box2d,并且我从“构建”和“分析”中收到大量警告。检查并确保项目的编译器在“构建设置”中的“编译器版本”下设置为 GCC 4.2。
I'm using Cocos2d and Box2d, and I get plenty of warnings from Build and Analyze. Check to make sure your project's compiler is set to GCC 4.2 under "Compiler Version" in the Build Settings.
对于任何可能遇到此线程的人(以及对于OP,以防问题仍然存在):
我在构建模拟器时遇到了这个问题。然而,切换到设备构建使分析器运行。
该网站可能会进一步阐明该问题: http://useyourloaf.com/blog/2010/10/5/xcode-build-and-analyze-broken-for-simulator.html
For anyone that might come across this thread (and for the OP in case the problem persists):
I had this problem when building for the Simulator. However, switching to Device build got the Analyzer running.
This site might shed some more light on the issue: http://useyourloaf.com/blog/2010/10/5/xcode-build-and-analyze-broken-for-simulator.html
我的 Cocos2d 游戏也收到了大量的分析警告。我清理了大部分,但是cocos2d 0.99.1内置了3个! (这应该很容易修复。)
我注意到有时分析器找不到东西,除非我在运行它时打开该特定文件......想想吧。
I also get plenty of Analyze warnings with my Cocos2d game. I cleaned most of them up, but cocos2d 0.99.1 has 3 built-in! (Which should be easily fixed.)
I have noticed that sometimes the analyzer doesn't find things unless I have that particular file open when I run it... go figure.