If you are like me, you are new to the whole IDE thing. If you are like me, you are used to using makefiles. Yes, I am talking about c++ Make files.
however, If you are like me, you want to use the power of Xcode to help you manage your code. So lets get started.
The reason I make this tutorial is because most of the stuff available is for past versions. sure, you can dig through Xcode 4 documentation, but chances are, you won't find it.
Lets give a brief introductions as to what IDE's do. Here are my favorite features.
1) Auto- complete
2) debugger
Auto-complete really helps when you hate memorizing function names. It also helps when you don't want to miss spell anything. for example what if you were working with an object but you forgot the name of the function?
Lets say we have an object "tempObj A" ; // tempObj is the type and A is the variable name
I simply have to type "A." that is "A" followed by a "." and it will give me suggestions. This is a very powerful tool and may be the reason you stick to IDE's
The debugger is very powerful. Much better then using the GDB in terminal. even though I had learned about the GDB in my intro to CS classes, I never bothered to use it. This is where IDE's make debuggers actually useful. When you run your code in debugging mode you can step through each line of code. You can even enter the function you were to call.
ok
Now to xcode.
If you are like me, then you have been using EMACS to edit all of your code. And if you are like me, then you want to use XCODE as an editor. You also want to use it so that you can "make" your program. By the end of this tutorial, you will be able to use a custom make file that will run your code.
1) Start a new project and select the empty
2) On the left you will see your project file. click it to highlight.
3) Look for the work target. Now click the button to make a new target.
4) create an external build system and follow the prompts
5) now targets should have a bulls eye looking thing under it. in the directory text box you are ring in insert the path to the directory that holds your makefile
6) now you need to add the files to your project. file-> add files to ....
now assuming you were able to make your program by typing "make" in the terminal.
you should be able to press the big play button at the lot left. It will compile your code.
But thats not all....you want it to run, right?
Well you have to edit the scheme.
once you do that, go to the run tab and change the executable to the name of your executable as per your make file. (i.e. a.out)
now when you click the big play button, you should be able to build and run the code.
Unfortunately.....you won't be able to make use of auto complete.
at least not yet =)
lucky for you I spent a very long time trying to looking at Xcode and reading documentation in order to tell you the short cut on how to do it.
if you want to enable autocomplete, you have to go under target membership. Unfortunately, the external built target doesn't like to be checked. So what you have to do is make another target but choose command line tool.
after you make it go back to "target membership" and check the box. You will have to do this for every file you select. Kind of annoying.
Just so you know, I may in the future add pictures to this blog. But only if you readers are having difficulty understanding my explanations in text.