Creating framework in Xcode with headers in different paths - c++

I made my own framework and saw that my test application could load the headers like
#include <global.h>
The problem is that this global.h has some more includes that are for instance in
<lol/head.h>
referring to the global.h. So the problem is that xcode cannot find those kind of headers, because when i create the framework, in the Target, my Copy Headers build phase has all the headers at the same level (the level of global.h) (all in the same folder in the framework).
Anyone can help me out on this? :) thks!

Well i found this other post with the the same question and some answers.
Keeping directory structure when creating frameworks in xcode
what i did was: create a run script copying the headers from the "base" directory to new folders inside that base directory. Now all the includes work fine ^^

You can include path where all the headers are placed.

Related

MiXiM include error

I created a project, which includes MiXiM.
The problem is that when I build the project I get this error:
/MiXiM/src/base/connectionManager/ConnectionManagerAccess.h:40:26: fatal error: BaseMobility.h: No such file or directory
I don't understand. The problem seems related to the MiXiM library but if I close my project, I can successfully compile every MiXiM example.
Is it a bug or am I doing smomething wrong?
You are probably trying to build MiXiM with a recent version of OMNeT++ (5.0 or later?). Since 5.0 OMNeT++ does NOT add all directories in the source tree as an include dir one by one. Only the root of the source folder is added. It means that ALL files that include other headers from a directory other than the current one MUST be prefixed with the path relative to the source folder root. Adding all directories to the include path was a very bad idea and was removed from OMNeT 5.
This leads to the next question: Why are you using MiXiM which is abandoned long ago and most of its functionality was merged into INET 3.x? Why not INET?
I don't know,if I can help you or not;but I had the same experience.
If you try to execute an old project in MIXIM with different version,you get this error.
For example,in MIXIM-2.2.1 there is BaseMobility;but in MIXIM-2.3 there is MobilityBase.Therefore,If your project was written in MIXIM-2.2.1,you should change it according to MIXIM-2.3.

Xcode folders and groups confusion

I'm using Xcode (with C++) and my project layout (in the file system, not in Xcode) looks like this:
SubfolderA
-file_A_1, file_A_2
SubfolderB
-file_B_1, file_B_2
Right now I've set up this structure in Xcode via groups. And so, when I want to include file_A_2 in file_B_1, I write #include "file_A_2" in file_B_1.
Is there some way to make an inclusion look like #include "/SubfolderA/file_A_2", so that I can easily see to what directory/subfolder an included file belongs?
One way to see what's going on is to look at the Build Log and expand the line for compiling sourcefile.m. Look at the -I options being passed to the compiler.
If it's not to your liking you can add the source tree in the Build Settings > Header Search Paths to include $(ProjectDir)/srcroot and make it recursive, which saves you from adding each sub-folder individually.
In my experience this has never been necessary, however, as far as I can remember.
As far as the Xcode folders are concerned, if the top-level source folder is added then all sub-folders are automatically added when you add them to the filesystem, saving the hassle of keeping them in sync. You might need to add the top-level folder under the Source Files group for this to work, however.
Surprisingly, in Xcode's Build Settings I've added to User Header Search Paths non-recursive path to my project. This solved my problem.
I ended up here when I was having an issue with XCode while trying to include a header in a group by doing
#include "MyGroup/MyHeader.h"
Turns out the project structure and the file system weren't in sync, so I just had to remove my group from the project, put it in the correct place in Finder, then drag and drop it back into the project in the correct place and it worked for me.
I'm not sure if this is necessary or not, but I also have already set up my app's working directory because I am doing some game programming and need to be able to load in .png and make textures.

Errors while porting cocos2d-x project to android

I have successfully run the "Step by Step Coos2dxSimpleGame Series" (http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Tutorials) in windows using visual c++. Now I want to port this project to an android device, Hence I copied the classes namely HelloWorld,AppDelegate and GameOverScene and their header files to Classes folder and the resources to /Resources folder. Then I have modified the android.mk file to include a new class called GameOverScene.cpp which is not present before .
Then I run ./build_native.sh . The error message is here (http://www.cocos2d-x.org/attachments/1152/native_error.PNG) .
Is the process I am following correct?
In HelloWorldScene.h, change:
HelloWorld::~HelloWorld();
HelloWorld::HelloWorld();
to:
~HelloWorld();
HelloWorld();`
You must not add the class name in your declarations in header files (but you have to do it in your cpp file).
One thing that I can suggest You is to follow step by step this tutorial
http://magicscrollsofcode.blogspot.com/2011/09/quick-and-dirty-guide-to-getting.html
and also don't forget about this:
http://www.cocos2d-x.org/boards/6/topics/8572?r=8577#message-8577 afterwards
these two things helped me a lot one time :)

xcode includes of header files

I am trying to compile a sample project for a browser plugin (http://pushingtheweb.com/2010/06/boilerplate-for-a-npapi-plugin/) using xcode 3.2.6 on Snow Leopard.
I have never used xcode before.
When I try to build I get an error with an include (AE/AERegistry.h: No such file or directory)
When I click on the file it takes me to the header file AE.h (which is in folder /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/Headers) and has the lines:
ifndef __AEREGISTRY__
include <AE/AERegistry.h>
endif
Firstly I dont know how to find out why AE.h is included in the build as I cant see it "included" anywhere.
Secondly why cant it find AERegistry.h which is in four separate locations on the computer?
I manually added one of the folders to the Header paths but it made no difference.
Why is it AE/AEReistry when it is not in a folder AE?
Thanks for any help
George
You'll have to go into the build settings, find "compiler flags"(CFLAGS), and add something like:
-I/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/Headers
And then do:
#include <AERegistry.h>

Working with Box2D/Cocos2D in an external iOS project

I have followed the instructions as per this article and have been working with Cocos2D without much issues. Recently, I tried including the Box2D headers to try some physics like so:
#import "Box2D.h"
This resulted in a lot of errors where the Box2D.h file could not include the rest of the header files:
../cocos2d-iphone-0.99.5/external/Box2d/Box2D/Box2D.h:34:0 ../cocos2d-iphone-0.99.5/external/Box2d/Box2D/Box2D.h:34:37: error: Box2D/Common/b2Settings.h: No such file or directory
That's the first error and the rest of the 23 are like that, but for the different headers in Box2D.h.
I have already added the projects/targets to the current project as per the instructions in the article, so my project currently looks like this:
Also, I have attempted to remedy this by selecting all .m files in my project and setting the file type to sourcecode.cpp.objcpp but do not think that this is the issue. I am certain that under the User Header Search Paths build setting, the folders where these headers are stored are added. If it weren't, Cocos2D wouldn't be able to compile either.
What am I doing wrong?
I don't know if this is immediately obvious to other programmers, but I fixed this by checking the Always Search User Paths setting in the target settings. Hope it helps someone else.
Another solition for me is removing blank characters from directory names. Forexample if your project folder such as
"user/prj 01"
change it to
"user/prj01".