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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With