Created
February 9, 2012 09:34
Revisions
-
wearhere revised this gist
Feb 9, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,8 +7,8 @@ # By setting Xcode (in Behaviors) to run this script when "Run Starts" # and when "Run Completes", you can prevent it from switching to main.m # when a run finishes. # See http://stackoverflow.com/questions/7682277/xcode-4-2-jumps-to-main-m-every-time-after-stopping-simulator # for a description of the problem and a bunch of solutions which don't work. # We use the defaults system to save the source path. # Change the domain to whatever you like. -
wearhere revised this gist
Feb 9, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ # We use the defaults system to save the source path. # Change the domain to whatever you like. DOMAIN="com.wearhere.keep_current_file_open" KEY="savedSourcePath" -
wearhere created this gist
Feb 9, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ #! /bin/sh # On alternate invocations, this script # saves the path of the source file currently open in Xcode # and restores the file at that path in Xcode. # # By setting Xcode (in Behaviors) to run this script when "Run Starts" # and when "Run Completes", you can prevent it from switching to main.m # when a run finishes. # See http://stackoverflow.com/questions/7682277/xcode-4-2-jumps-to-main-m-every-time-after-stopping-simulator for a description of the problem # and all the solutions which don't work. # We use the defaults system to save the source path. # Change the domain to whatever you like. DOMAIN="com.jeffwear.keep_current_file_open" KEY="savedSourcePath" # The first time this script is invoked, this call will return a "does not exist" error. # The second time this script it invoked, this call will return the saved source path. # We copy stderr to stdout so that we can read both results using a single call. savedSourcePath=`defaults read $DOMAIN $KEY 2>&1` if [[ "$savedSourcePath" == *"does not exist"* ]]; then # read path of current source file out of Xcode sourcePath="`osascript << EOT tell application "Xcode" set windowName to (name of first window) set currentFileName to item 2 of (words of windowName) set currentSourceDocument to first item of (source documents whose name ends with currentFileName) set currentSourceFile to (file of currentSourceDocument) set currentSourcePath to (POSIX path of currentSourceFile) end tell return currentSourcePath EOT`" # save current source path defaults write $DOMAIN $KEY "$sourcePath" else # open saved source path in Xcode open "$savedSourcePath" # clear saved source path defaults delete $DOMAIN $KEY fi