Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import "cocos2d.h" works in some files, but not all

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.

like image 536
Rahul Iyer Avatar asked Mar 21 '12 05:03

Rahul Iyer


3 Answers

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.

like image 119
Rahul Iyer Avatar answered Oct 13 '22 17:10

Rahul Iyer


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/**")

like image 3
Questor Avatar answered Oct 13 '22 19:10

Questor


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.

like image 2
Neil Galiaskarov Avatar answered Oct 13 '22 17:10

Neil Galiaskarov