i am using cocos2d template with Box2d but when i import Box2d.h in my project it gives me error cassert fiel not found i have cocos2d version 2.0 please help me
5 Answers
Make sure all your project's source code files have the file extension .mm and not .m. Or set each .m file's type to Objective-C++.

- 64,284
- 20
- 132
- 217
-
i change file extension .m to .mm but just those files which i was created. here is lots od cocos2d files founds with.m – Faheem Rajput Aug 24 '12 at 11:59
Changing extension in xcode 4 will not work. Instead go to build settings (tab) and change C++ standard library setting to libc++ (LLVM...) from compiler default.
If you build it now you will get an error saying app is not compatible with iOS 5 or later. So go to summary (tab) and change deployment target to 5.0. It should now build successfully.
Here is how I fixed the issue. Cleaning up and recreating the project didn't seem to be a good idea for me.
There are a couple of answers on the web for this issue but they in each didn't help me solve the problem. One is on SO at
cassert file not found but i use Box2d template and the other is on cocos2d-iphone forum,
Combining the two suggestions kind of worked for me -
- Rename all YOUR (not cocos2d or box2d files, just your project files) from .m to .mm
- Make sure that on each of the files, on the right pane, “Type” option is set to “Default – Objective C++ Source”
There was another issue for me specifically, may not be an issue for you, I was using the following signature for CCLabelTTF
CCLabelTTF *title = [CCLabelTTF labelWithString:@"Hello" dimensions:CGSizeMake(720.0f, 880.0f) alignment:UITextAlignmentLeft fontName:@"Arial" fontSize:34];
This is deprecated and caused errors all over the place. I am now using the following slightly modified version and the errors fixed -
CCLabelTTF *title = [CCLabelTTF labelWithString:@"Hello" dimensions:CGSizeMake(720.0f, 880.0f) hAlignment:kCCTextAlignmentRight fontName:@"Arial" fontSize:34];
My most recent writeup of this fix can be found at - http://indiangamer.com/how-i-fixed-the-cocos2d-box2d-include-file-not-found-error/

- 1
- 1

- 325
- 2
- 7
For those like me : I just tried to reopen a very old xcode project and got this error with cassert files.
Just setting the target to a new one (iOS 13 in my case) made it automatically select the correct version of the c++ stdlib and everything worked just fine.

- 3,965
- 3
- 30
- 34