Create -> Project -> Application with one view...">

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

Here is what I did:

In Xcode 4.3.1

File -> Create -> Project -> Application with one view

Drag and drop the cocos2d-ios.xcodeproj file into the navigator.

In the settings of the assembly phases: 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 for user paths" to YES Added cocos2d source directory to "User header search paths"

Now, it seems, I can type: import "cocos2d.h", in the delegate deletion of the application and the root view controller created by Xcode. But if I create a new file and I add the line "import" cocos2d.h "" at the top, Xcode complains that the file was not found. But that seems to be fine. Also, in this new code, the code code does not work.

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

EDIT: It seems to be building and working fine. I can call methods in cocos2d api. the meaning of the code just does not look like cocos2d.h in the new files that I create.

EDIT - it seems that the meaning of the code is prompted by cocos2d.h when I type: import "But it does not offer classes / methods from cocos2d api.

+6
source share
3 answers

It turns out I just added the "user header search path" to my goal, but not in the project settings.

Adding this is fixed. I think that the reason it was compiled is due to the fact that I added it to the target, but it did not work in a text editor, since I did not add it to the project.

+3
source

This happened to me, although I added it both to the project and to the goal.

However, it worked for me to select the RECURSIVE flag in the "User Header Search Prefix" section (which was set to "/ lib / **")

+3
source

I had the same problem.

My project → Build Settings
Find an entry for search paths

Always search for user paths - YES

User header search paths are "myProjectName / libs" // I put the box2d folder here

Hope this helps someone.

+2
source

Source: https://habr.com/ru/post/911264/


All Articles