Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one compile single file Xcode 4?

While I used to compile a single source file with Cmd+K in prior versions of Xcode, how does one do the same in Xcode 4? (Note that this is different than preprocessing or showing the disassembly of the file.) If compiling from a command line is proposed then it must be such that the project's settings, include paths, preprocessor definitions, etc., are all included.

An example use case is where I make a header file change but only want to test the change's effect with respect to a single source file, not all of the files that depend upon that header.

like image 269
sergey Avatar asked Jan 18 '11 18:01

sergey


People also ask

How do I run a single file in Xcode?

Go to File->New->Target to create a new target. From the sounds of it, you are creating a command-line C program, so you will want to create a Command-Line Tool found under OS X-> Application . If that doesn't work, make sure the command line tools are installed.

How do I compile only in Visual Studio?

Ctrl+F7 will compile only the active source file. Look for the Compile item at the bottom of the Build menu. Of course, you'll still have to do a build before you can test, but if you just want a quick sanity check after modifying a source file, this can be handy.


1 Answers

The command has been moved to the Perform Action submenu. Look under

Product > Perform Action > Compile filename.cpp 

To assign Cmd+K to it, go to

File > Preferences > Key Bindings > Product Menu group 

and you'll find Compile File where you can assign a key. Cmd+K is assigned to Clear Console now by default, so be sure to remove that binding to avoid conflicts.

like image 185
John Stephen Avatar answered Nov 12 '22 07:11

John Stephen