Compiling existing C++ code in my iOS project

Posts: 1
Joined: 2012.04
Post: #1
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" ?
Quote this message in a reply
Posts: 112
Joined: 2002.06
Post: #2
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.

Mark Szymczyk
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  XCode project build options + makefiles = compiling fun! Lavareef 2 7,525 Nov 10, 2005 04:30 PM
Last Post: dair
  Problems with compiling code vbuser1338 3 4,489 Oct 28, 2005 02:48 PM
Last Post: vbuser1338