I'm trying to emulate Xcode's ⌘-R keystroke in another editor (namely, Vim); I thought I would be able to do this with some shell scripting & applescript, but it doesn't seem to be working correctly:
open -a Xcode "MyProj.xcodeproj"
osascript -e 'tell app "Xcode"' -e 'build' -e 'launch' -e 'end tell'
The problem with this is it launches the app regardless of whether Xcode reports errors. Is there any way to fix this?
I use:
osascript -e 'tell application "Xcode"
activate
set targetProject to active workspace document
if (build targetProject) is equal to "Build succeeded" then
launch targetProject
end if
end tell'
Of course, the project has to already be open in Xcode for this to work. (I'd rather not hard code the current project into my script)
Unless you really want the Xcode GUI, you could just use xcodebuild instead of launching and scripting Xcode.
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