Compile and Run C Code in TextWrangler
by georgeg4 in Circuits > Apple
14495 Views, 15 Favorites, 0 Comments
Compile and Run C Code in TextWrangler




In this tutorial i'll be demonstrating how to compile and run C code right inside of TextWrangler using Xcode's GCC C compiler , I assume that you have already installed Xcode's command line tools and i'll not be explaining how to do that in this tutorial , if you haven't , check this tutorial on OS X Daily first.
The AppleScript

i made this apple script to use Xcode's GCC C compiler to compile and run the C file being edited in TextWrangler , it saves the changes made , compiles it to an app called "output" , then runs this "output" app.
the compiled app is saved in the same location of the C file.
download this AppleScript here.
Put the Script in TextWrangler



Open up TextWrangler , then go to "Script menu > Open Scripts Folder"
Copy the AppleScript to TextWrangler's Scripts folder.
A new item should appear in the Scripts menu called "C compile and run".
Set a Shortcut (Optional)



Open TextWrangler's preferences.
Navigate to "Menues & Shortcuts" > "Scripts" > "C compile and run"
Click it to set a keyboard shortcut.
I've set mine to "CMD ." , choose whatever you want but make sure not to replace a previously set default shortcut.
Enjoy Your Development

Enjoy developing your C code , and don't forget to check my other projects on my website George Gabra Jr.