Compiling existing C++ code in my iOS project - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Tools & Technology (/forum-10.html)
+--- Thread: Compiling existing C++ code in my iOS project (/thread-9984.html)
Compiling existing C++ code in my iOS project - olafure - Apr 13, 2012 02:46 AM
Scene: I'm porting my C++ game to iOS and having some issues with getting things started.
I'm having problems getting XCode 4.3 to acknowledge that my C++ code exists and compile it.
I've set up a new project, added the header search path. Inluding C++ header files therefore works.
If I add a single C++ source file from my C++ codebase to my XCode project via "Compile Sources" build phase, that file is included in the build and all looks good.
However, I have a bunch of source files in my existing C++ codebase tree and I'd rather not add them all manually.
I can add the whole C++ codebase directory in "Compile Sources" directory, but then XCode asks me to "Create external build system project". If I do that (and add the resulting target as a dependency to the main target), no C++ files get compiled . Presumably because of a missing Makefile for my codebase ?
So. Do I have to make my own Makefile? If so, that's OK. I have my own GNU makefile for Linux. But what are the compiler arguments, who does the linking, ... ? Is there a makefile template for this type of situation ?
It seems slightly mad to write a Makefile for use within XCode, but is that my only option if I don't want to add a million source files directly to my Target's "Compile Sources" ?
RE: Compiling existing C++ code in my iOS project - szymczyk - Apr 13, 2012 10:28 AM
Add the folder of C++ files to your project by choosing File > Add Files to ProjectName. In the Open panel you will see a Folders group with two radio buttons. Select the Create groups for any added folders radio buttons.
If adding the folder to the project doesn't add all the files to the Compile Sources build phase, click the + button to add them. You can select multiple files to add by shift-clicking and command-clicking so you don't have to add them one at a time. In your case, clicking the first file in your C++ file folder and shift-clicking the last file should select all of the files in the folder.