iOS Simulator Switching Devices

With Apple’s latest products, including the iPhone 5 we now have to worry about more form factors then ever. As the method for switching the device type in Titanium Studio is still pretty clumsy I went in search of an earlier way.

The Appcelerator forums had a great post by Rob Gabbard with an AppleScript helper to do just what I was looking for. With a small update to add support for the Retina iPad and iPhone 5 I can now switch devices must easier.

I wanted to share a link to this script for anyone that might have missed the QA post. Unfortunately this doesn’t address the need for the app to be launched again when the device is changed.

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

View the the gist of the script.

Creating Keyboard Shortcuts for Switching Tabs in Titanium Studio

I’ve been using Titanium Studio quite a bit lately and noticed the default key mappings for switching tabs was not working for me.  Titanium Studio allows you to easily set your key bindings to anything.

Below are the steps I used to create my tab switching shortcuts.

Where is Key Mapping Preferences?

You can updated Titanium Studio’s key bindings by going to Titanium Studio then selecting the Preferences option as shown below.

PreferencesOption

Titanium Studio provides a large amount of preferences, you can tailor almost anything to your workflow.  The key binds are found under General then Keys.  If you have trouble finding this, just search for “keys” in the filter box.

PreferenceKeyOption

Mapping Next Tab

Once in the Keys option menu, scroll until you see “Next Tab”, you can also filter by “tab” and it will help you find this option.  Select the “Next Tab” as shown in orange below. Then enter “Command Page Up” in the binding section highlighted in blue. Once completed you will need to press the “Apply” button for this option to be immediately available in Titanium Studio.

NextTab

Mapping Previous Tab

Once in the Keys option menu, scroll until you see “Previous Tab”, you can also filter by “tab” and it will help you find this option.  Select the “Previous Tab” as shown in orange below. Then enter “Command Page Down” in the binding section highlighted in blue. Once completed you will need to press the “Apply” button for this option to be immediately available in Titanium Studio.

PreviousTab

Shortcuts in Action…

Now I can switch between tabs just like in my Eclipse projects.

Moving to the Next Tab

Tab1Selected

CMD  jean_victor_balin_add_blue  UAK

Tab2Selected

Moving to Previous Tab

Tab2Selected

CMD  jean_victor_balin_add_blue  DAK

Tab1Selected