How to add Box2d to an existing Xcode / Cocos2d project

I have a working Xcode project that includes Cocos2d in one of the views. Now I need to add Box2d. I tried to drag the Box2D folder into the libs directory of my cocos2d-2.x-ARC-iOS folder and add to this purpose, but I get this when compiling:

(in b2BroadPhase.cpp)
'Box2D/Collision/b2BroadPhase.h' file not found

I am sure that this is only the first of many errors that I will receive. What step am I missing to compile all the Box2d files compiled in my project?

All box2d files are listed in compilation sources for the purpose of cocos2d-library.

And why is it so hard to do? Why doesn't it work like any other library?

And - do I need to rename every .m in my project to .mm? This is almost impossible, as it is a large xcode project with many files. I'm just trying to use Box2d in one view.


Additional information in response to the response received by LearnCocos2D -

My folder structure (in Finder) looks like this:

Root = MyProject.xcodeproj, MyProject folder, cocos2d-2.x-ARC-iOS folder The cocos2d-2.x-ARC-iOS folder has a libs folder. Inside this folder, I have a Box2D folder, as well as Cocos2d, CocosDenshion, etc.

In Xcode, I have PROJECT (MyProject) AND 2 TARGETS (cocos2d-library, MyProject) There are "header search paths" for PROJECT and TARGETS. Which one did I install? And should it be recursive or not? And when I drag the Box2D folder into Xcode, for what purpose do I set it?

/Users/me/Dropbox/iOS/MyProject. , ? /Users/me/Dropbox/iOS/MyProject/cocos 2d-2.x-ARC-iOS/libs, , .


-/Users/me/Dropbox/iOS/MyProject/cocos2d-2.x-ARC-iOS/libs MyProject TARGET, , Box2D. "cassert", . , , AppDelegate "Objective-C ++ Source", . ...

NSObjCRuntime.h NSZone.h, NSObject ( unqualified-id, name 'NSString' ..). , , Box2d/Cocos2d, UIKit. .

+5
3

: Box2D. . , .

, Box2D:

Box2D.h . , :

Box2D.h /Projects/MyProject/libs/Box2D

... /Projects/MyProject/libs

, Box2D #include Box2D:

#include <Box2D/Common/b2Settings.h>

, # include/# import :

/Projects/MyProject/libs/Box2D/Common/b2Settings.h

, .

, , . , Box2D <file.h>. "file.h", , .

? . . . , . . , . . 5 , 10 .:)

.m , Box2D, (#import "Box2D.h"), ( , Box2D). Box2D Prefix.pch, , , .

, .m Xcode "Objective-C ++". , . . , , .

+7

: $ [Project_dir]

+2

:

  • " ": , Box2Ds. Box2D , ${PROJECT_DIR}. "". . Box2D . : TestGame/Libraries/Box2D → ${PROJECT_DIR}/TestGame/Libraries

  • Cpp , <cassert>...: *.mm *.m, .

0

All Articles