How to Compile a .C File in Xcode 4

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)

Posted on Nov 30, 2012 8:30 PM

Reply
1 reply

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...":

User uploaded file


Now select the "Command Line Tool":

User uploaded file


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:

User uploaded file


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:

User uploaded file


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.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to Compile a .C File in Xcode 4

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.