Skip to content
School of Physics
Home Our Teaching Resources C programming xcode.html
Back to top

Tips for using XCode

Running XCode for the first time

  1. From Finder choose: Window -> Applications
  2. Find XCode 2.5 at the bottom and open it.
  3. When the XCode icon appears in the Dock click on it, hold down the mouse, then select "Keep in Dock".

    When returning to a project, open XCode 2.5 from your dock and choose File -> Recent

Creating a project

  1. Start up XCode if it not already running.
  2. Choose: File -> New Project
  3. Select @Exeter Physics (second one down) then Next
  4. Choose a sensible name
  5. Your program text is in the file "main.c", double-click to edit it. Do not User Word, etc to edit your text file!
  6. When you come to print your program, print directly from within XCode, don't copy and paste into Microsoft Word!
When 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 warnings

When you compile the system may flag up two types of problems: errors and warnings.

Errors

Errors are indicated by Red circles and denote code that is not valid C. The program will not compile or run.

Warnings

Warnings 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 are

Error 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 them

In 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.

                                                                                                                                                                                                                                                                       

Validate   Link-check © Copyright & disclaimer Share
Back to top