![]() | Physics and Astronomy |
Back to top
Tips for using XCode on the MacsRunning XCode for the first timeNB: Charles Williams has produced helpful video demonstrating the process, this is best run sitting at the Mac after reading these notes.
Creating a project
Seeing the output (console)Before running your program for the first time, go to the Run menu and choose Run -> Console (or Command-R). This brings up a window with your progam's output. You should be able to make this happen automatically from the XCode menu: XCode -> Preferences -> Debugging -> On Start -> Show console -> Running your programWhen you want to run your code click "Build and Run".Note:To insert a hash sign (#) type Alt-3 (i.e. press and hold down the "Alt" key and press "3", just like using the shift key). Also notice that it's the "Alt" key, not the "Apple" key. Errors and warningsWhen you compile the system may flag up two types of problems: errors and warnings. ErrorsErrors are indicated by Red circles and denote code that is not valid C. The program will not compile or run.WarningsWarnings are indicated by Amber triangles. Technically, this code is valid and system will compile and run it. But it probably means you have made a mistake so fix it. Seeing what they areError and warning alerts appear in two places: in the left-hand margin by the side of the individual lines with problems and at the bottom right of the window. To view all errors and warnings at once, click on the red circle or amber triangle at the bottom right of the page. To view an individual error or warning, move your mouse over the relevant warning sign at the left of the code line and wait a couple of seconds. Fixing themIn general, fix problems starting with the first one as this may also fix later problems. One of the most potentially confusing errors is "Parse error" (or"Syntax error")which means you have made a mistake in your punctuation. It will tell you the character ("token") that it saw when it was expecting to see something else. |