Skip to content

Instantly share code, notes, and snippets.

@rgabbard
Created August 24, 2011 15:03
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rgabbard/1168261 to your computer and use it in GitHub Desktop.
Save rgabbard/1168261 to your computer and use it in GitHub Desktop.
AppleScript to set the active device type when the iOS Simulator launches
set selectedDevices to choose from list {"iPhone", "iPhone (Retina)", "iPad"} with prompt "Choose device type:" default items {"iPhone"} without multiple selections allowed
if selectedDevices is not false then
set selectedDevice to item 1 of selectedDevices as string
set thePListFolderPath to path to preferences folder from user domain as string
set thePListPath to thePListFolderPath & "com.apple.iphonesimulator.plist"
tell application "System Events"
tell property list file thePListPath
tell contents
set value of property list item "SimulateDevice" to selectedDevice
end tell
end tell
end tell
end if
@benbahrenburg
Copy link

Updated with the iPhone 5, and Retina iPad


set selectedDevices to choose from list {"iPhone", "iPhone (Retina 3.5-inch)", "iPhone (Retina 4-inch)", "iPad", "iPad (Retina)"} with prompt "Choose device type:" default items {"iPhone"} without multiple selections allowed
if selectedDevices is not false then
    set selectedDevice to item 1 of selectedDevices as string
    set thePListFolderPath to path to preferences folder from user domain as string
    set thePListPath to thePListFolderPath & "com.apple.iphonesimulator.plist"
    
    tell application "System Events"
        tell property list file thePListPath
            tell contents
                set value of property list item "SimulateDevice" to selectedDevice
            end tell
        end tell
    end tell
end if

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment