7

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

Faheem Rajput
  • 591
  • 4
  • 8
  • 17

5 Answers5

24

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++.

CodeSmile
  • 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
1

change your file extension .mm thats it

Hardik rami
  • 359
  • 4
  • 15
0

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.

chappjc
  • 30,359
  • 6
  • 75
  • 132
kenil
  • 1
0

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,

http://www.cocos2d-iphone.org/forums/topic/cannot-include-box2d-cassert-file-not-found-despite-every-file-being-mm/

Combining the two suggestions kind of worked for me -

  1. Rename all YOUR (not cocos2d or box2d files, just your project files) from .m to .mm
  2. 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/

Community
  • 1
  • 1
Madhav Sbss
  • 325
  • 2
  • 7
0

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.

Ben G
  • 3,965
  • 3
  • 30
  • 34