6

Here is what I did:

In Xcode 4.3.1

File -> New -> Project -> Single view application

Dragged the file cocos2d-ios.xcodeproj into navigator.

In build phases settings : Added : libcocos2d.a (becomes highlighted in red), as a linked library (required).

Added OpenGles.framework, Quartzcore, and libz.dylib

Changed build settings - Set "Always Search User Paths" to YES Added cocos2d source directory to "User Header Search Paths"

Now, it seems I can type: import "cocos2d.h" , in the app delegate and root view controller that Xcode created. But if I create a new file, and I add the line "import "cocos2d.h"" to the top, Xcode complains that the file is not found. But it seems to build fine. Also, in this new file code sense does not work.

What should I do? Why can I import only in the files that Xcode created? Is there some setting I need to change so that in the files I create, I can import cocos2d ?

EDIT: It seems to build and run fine. I can call methods in the cocos2d api. code sense just doesn't seem to see cocos2d.h in the new files I create.

EDIT - it seems that code sense suggests cocos2d.h when i type : import " But it does not suggest classes / methods from the cocos2d api.

Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190
  • what do you need to get? Do you need to see the examples from the sdk or simply to create your own project? I have installed cocos2d and it full of bugs. So your problem is not onest – Gargo Mar 21 '12 at 06:53
  • I was adding the cocos2d project to my main project so that it would be easier to swap versions of cocos2d later on. I didn't wan't to use the template. cocos2d may have some bugs, but most of the api that I use is stable and working. – Rahul Iyer Mar 22 '12 at 03:35

3 Answers3

3

This happened to me as well, even though I did add it to both project and target.

However, what worked for me was to select the RECURSIVE checkbox under "User Header Search Prefixes" (which was set to "/lib/**")

Questor
  • 376
  • 4
  • 8
3

Turns out I had only added the "user header search paths" to my target, but not in the project settings.

Adding it fixed the problem. I guess the reason it compiled fine was because I had added it to the target, but it didn't work in the text editor since I hadn't added it to the project.

Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190
2

I had same issue.

My project -> Build Settings
Look for the entry for Search Paths

Always Search User Paths - YES

User Header Search paths - "myProjectName/libs" //I put box2d folder here

Hope this help someone.

Neil Galiaskarov
  • 5,015
  • 2
  • 27
  • 46