Skip navigation

How to Compile a .C File in Xcode 4

1044 Views 1 Reply Latest reply: Dec 1, 2012 7:09 AM by Wayne Contello RSS
Weatherlord Catrina Calculating status...
Currently Being Moderated
Nov 30, 2012 8:30 PM

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)
  • Wayne Contello Level 6 Level 6 (12,640 points)
    Currently Being Moderated
    Dec 1, 2012 7:09 AM (in response to Weatherlord Catrina)

    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.


More Like This

  • Retrieving data ...

Bookmarked By (0)


  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.