Xcode 4 Autocomplete with C ++ library?

I am using Cocos2D Box2D template for my project.

When I type "b2 **", autocomplete does not display Box2D classes. (pressing ESC also does not show) I have included Box2D.h and Cocos2d.h in the file "Prefix.pch".

Is there any function like "rebuild index" in "Eclipse CDT"?

Any tips?

+4
source share
5 answers

This page lists the steps taken by another user to get the code completed for Xcode 4 and Box2D - the steps include deleting the derived data folder, but also changing the search paths for user headers, making sure that there are no spaces or other things along the way to the project. Some of these steps may be random or unrelated, but apparently they fixed the problem for two people in this forum.

+1
source

You can force Xcode to rebuild the index by deleting its service folder ( DerivedData strong> for Xcode 4.x):

  • Close Xcode
  • Delete service folder
  • Open the project and Xcode will restore the index again.

In my case, this always works, and I can call b2 ... autosuggest.

The DerivedData strong> folder can be found in ~ / Library / Developer / Xcode / DerivedData p>

+8
source

This may be an obvious suggestion, but have you tried to introduce a class that, as you know, exists with what you included, and see if it recognizes it (both with coloring and with quick help)? In addition, do you have the necessary framework, etc.? As for overloading, the only thing you can do in Xcode that I know of is clean (shift + cmd + k) and reassembly. Do you get any warnings, errors, etc.? Another potentially obvious problem: Is Xcode installed in C ++ as a language? In any case, I hope you have not tried it all, and it helps you get somewhere.

+2
source

Assuming you are using Xcode 4, you can simply rebuild the index:

  • Open Organizer (Command + Shift + 2)
  • Click "Projects" at the top
  • Select the project you want to rebuild for the index in the left sidebar
  • Click "Delete" next to "Derived Data" in the central part of the Organizer.

This is easier than navigating directories and manually deleting a number of folders.

+2
source

By combining all of the above entries together, I decided to solve my problem:

1) Make sure all files are in the same folder. This may seem obvious, but my Box2D files were not in the same folder as my other code. When you create a new project using Xcode, it creates a folder with the name of your project, and then another folder inside the one that again has the name of the project. Example: "{project path] / TempProject / TempProject". I had Box2D files in the first TempProject directory, and not with the rest of the code that is being created in the TempProject subdirectory.

2) Open your project settings by double-clicking your project in Xcode

3) Scroll down to Search Path

4) Edit the value for “Header Search Paths”: $ {SOURCE_ROOT} / $ {PROJECT_NAME} / ** (Note: If your Xcode does NOT create a subdirectory like my, this is “TempProject / TempProject”, then just use $ {SOURCE_ROOT} / **)

5) Delete your Derived Data project by doing one of the following two methods:

a) Open Organizer → Select projects → Select project → Select Delete next to the project’s derived data

b) Open Finder → Choose Go from the toolbar → enter “~ / Library / Developer / Xcode / DerivedData” → Find and delete the desired project folder

6) Restart Xcode

7) Clear and rebuild code

8) Now the meaning of the code should work!

+1
source

All Articles