Monday April 08, 2013

Self Compiling Objective-C Files

I did a lot of experimenting with Core Data as I prepared for my talk at the RubyMotion #inspect conference. I needed to run Objective-C files over and over again while I compared accessing the framework from RubyMotion. My workflow increased when I found this tip by Nicolas Bouilleaud to make Objective-C source files executable in the same way that you make a script file executable with a hash-bang line at the top. By crafting a custom command in a special comment at the top of the file, you can mark an Objective-C script executable with chmod +x and run it like a shell script. It will automatically compile, link, and run the resulting binary from the current directory.

From the fun to know department.