Build and run current xcode project from command line
Alec Jacobson
June 18, 2010
I edit my source code via the command line using vim. Then I need to go into xcode and push build/run to debug the code I'm working on. I'd rather just issue a command from vim. Here's a cheap way to build and run via and applescript which can then be called by vim.
Save the following applescript as xcode_build_and_launch.scpt
tell application "Xcode"
activate
set targetProject to project of active project document
if (build targetProject) starts with "Build succeeded" then
launch targetProject
end if
end tell
Then from vim you can issue:
:!osascript path/to/xcode_build_and_launch.scpt
This will activate xcode and build the current project, and if that succeeds then it will launch the current executable target.
Note: I stripped the above out of code from a question on stackoverflow. Apparently this will not work for iPhone simulator projects.
Update: I like to call it from vim with the bash time
command and then I have an idea of how long the compile took.
:!time osascript path/to/xcode_build_and_launch.scpt