1 Reply Latest reply: Dec 1, 2012 7:09 AM by Wayne Contello
Weatherlord Catrina Level 1 Level 1 (0 points)

Why are the "Run", "Build", "Debug" options greyed out when I have a .C file open? Why can't I compile a .C file in Xcode 4?


iMac, Mac OS X (10.7.5)
  • 1. Re: How to Compile a .C File in Xcode 4
    Wayne Contello Level 6 Level 6 (13,615 points)

    You should create a new command line project, then add your c file to the project (removing the c file that the project already has), then compile.

     

    To create a new project select the menu item "File > New > Project...":

    Screen Shot 2012-12-01 at 8.58.41 AM.png

     

    Now select the "Command Line Tool":

    Screen Shot 2012-12-01 at 9.00.33 AM.png

     

    Follow the prompt to enter the name of the project, then where to store the project.  When you have completed, click the file main.c and you should see a window like:

    Screen Shot 2012-12-01 at 9.03.20 AM.png

     

    I suggest compiling and running this first.  To run the program select the menu item "Product > Run".  XCode will compile, link, then run the program.  You see the output window appear like:

    Screen Shot 2012-12-01 at 9.06.47 AM.png

     

    Once you have done this.  you can replace the main.c file with your own OR replace the contents of this main.c file with the contents of your file by copy and paste.