Using Xcode with GNU Make

I think no one will argue that writing code in the IDE is much more convenient than, say, in vim or some other “just editor”. Here, and syntax highlighting (in fairness it should be noted that it is in almost all editors) and auto-completion and close connection with the debugger. Sometimes documentation. Well, in general, a lot of different nice things.
But it so happened historically that each IDE stores a description of the assembly parameters in its own way. Often in a completely unsightly form. This does not create problems if development is carried out on the target platform. And if the code is cross-platform? And on other platforms (yes even if at least on one of them) the required IDE is missing?

So I encountered such a problem: I have a poppy on the workplace (I use Xcode as an IDE), and I write network code that should work on a wide range of equipment, starting with the iPhone and ending with the Sony PS.
Xcode is a pretty good IDE. There are no serious complaints against her. Well, except for the strange format of the “project”.

But it turns out not so bad as it seems on the first look. And after some unobvious, but very simple steps, we can accustom Xcode to GNU Make. At the same time, we get both a convenient IDE and all the power of make. And make is on platforms I haven’t even heard of.
Getting down.

Create a project template

We start Xcode and in the File menu we select the New Project item.
Next, when choosing “template”, select “Other” -> “External Build System”.
As usual, enter the name of the project.

At this stage, we have a project template. Good. We continue.

Create a new “target”

In the "Project" menu, select "New Target".
In the window that appears, select “Other” -> “External Target”. We press the “Next” button and we get a new window where we enter the target`a name (Enter any - this has nothing to do with file names, etc. This just indicates how target will be named in Xcode)
Double-click on the new target and in field "Directory" indicate the directory in which the Makefile is located.
Next, in the “Progect” menu using the “Set Active Target” item, we make our new target active. The old target can be removed with a clear conscience.

Add source code to the project

Now we add the source code to the project in the usual way.
No copying! Let it remain in its place.

Specify the path to the executable file

In the "Project" menu, select "New Custom Executable" and in the column "Executable Path" indicate the path to the directory where Make will collect your project. Well, add the file name at the end.
Those. you must enter the path to the resulting executable file.
Click Finish and we can use it.


Further actions are no different from the usual use of Xcode.

This "recipe" was cross-checked for versions of Xcode 3.2.3 and 3.2.4. I don’t intentionally give screenshots, since the algorithm works for much older versions of the IDE, but the interface is slightly different.

Use for health!

Also popular now: