Skip to content

Instantly share code, notes, and snippets.

@patriknyblad
Last active May 4, 2026 21:55
Show Gist options
  • Select an option

  • Save patriknyblad/be3678bf6b515f11b602051530b5ac3e to your computer and use it in GitHub Desktop.

Select an option

Save patriknyblad/be3678bf6b515f11b602051530b5ac3e to your computer and use it in GitHub Desktop.

Revisions

  1. patriknyblad revised this gist May 13, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions xcrun_simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -149,7 +149,7 @@ done
    ```

    ###### References:
    https://medium.com/@ankitkumargupta/ios-simulator-command-line-tricks-ee58054d30f4
    https://medium.com/xcblog/simctl-control-ios-simulators-from-command-line-78b9006a20dc
    https://nshipster.com/simctl/
    https://www.linuxjournal.com/content/bash-arrays
    * https://medium.com/@ankitkumargupta/ios-simulator-command-line-tricks-ee58054d30f4
    * https://medium.com/xcblog/simctl-control-ios-simulators-from-command-line-78b9006a20dc
    * https://nshipster.com/simctl/
    * https://www.linuxjournal.com/content/bash-arrays
  2. patriknyblad revised this gist May 13, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xcrun_simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -152,4 +152,4 @@ done
    https://medium.com/@ankitkumargupta/ios-simulator-command-line-tricks-ee58054d30f4
    https://medium.com/xcblog/simctl-control-ios-simulators-from-command-line-78b9006a20dc
    https://nshipster.com/simctl/
    https://www.linuxjournal.com/content/bash-arrays
    https://www.linuxjournal.com/content/bash-arrays
  3. patriknyblad revised this gist May 13, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion xcrun_simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -151,4 +151,5 @@ done
    ###### References:
    https://medium.com/@ankitkumargupta/ios-simulator-command-line-tricks-ee58054d30f4
    https://medium.com/xcblog/simctl-control-ios-simulators-from-command-line-78b9006a20dc
    https://nshipster.com/simctl/
    https://nshipster.com/simctl/
    https://www.linuxjournal.com/content/bash-arrays
  4. patriknyblad revised this gist May 13, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xcrun_simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Managing simulators
    # Managing iOS Simulators

    ### List all simulators created
    ```
  5. patriknyblad revised this gist May 13, 2019. 1 changed file with 21 additions and 21 deletions.
    42 changes: 21 additions & 21 deletions xcrun_simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -123,27 +123,27 @@ OPEN_URL="myapp://some/page/in/app" # Deep linking
    echo "Running on ${#SIMULATORS[*]} simulators."
    for index in ${!SIMULATORS[*]}
    do
    SIMULATOR=${SIMULATORS[$index]}
    echo "Booting ${SIMULATOR}..."
    xcrun simctl boot "${SIMULATOR}"
    if [ ! -z "$APP_PATH" ]
    then
    echo "${SIMULATOR} installing: ${APP_PATH##*/}"
    xcrun simctl install "${SIMULATOR}" "${APP_PATH}"
    fi
    if [ ! -z "$APP_IDENTIFIER" ]
    then
    echo "${SIMULATOR} opening app: ${APP_IDENTIFIER}"
    xcrun simctl launch "${SIMULATOR}" "${APP_IDENTIFIER}"
    fi
    if [ ! -z "$OPEN_URL" ]
    then
    echo "${SIMULATOR} opening url: ${OPEN_URL}"
    xcrun simctl openurl "${SIMULATOR}" "${OPEN_URL}"
    fi
    SIMULATOR=${SIMULATORS[$index]}
    echo "Booting ${SIMULATOR}..."
    xcrun simctl boot "${SIMULATOR}"
    if [ ! -z "$APP_PATH" ]
    then
    echo "${SIMULATOR} installing: ${APP_PATH##*/}"
    xcrun simctl install "${SIMULATOR}" "${APP_PATH}"
    fi
    if [ ! -z "$APP_IDENTIFIER" ]
    then
    echo "${SIMULATOR} opening app: ${APP_IDENTIFIER}"
    xcrun simctl launch "${SIMULATOR}" "${APP_IDENTIFIER}"
    fi
    if [ ! -z "$OPEN_URL" ]
    then
    echo "${SIMULATOR} opening url: ${OPEN_URL}"
    xcrun simctl openurl "${SIMULATOR}" "${OPEN_URL}"
    fi
    done
    ```
  6. patriknyblad revised this gist May 13, 2019. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions xcrun_simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -130,18 +130,18 @@ do
    if [ ! -z "$APP_PATH" ]
    then
    echo "${SIMULATOR} installing: ${APP_PATH##*/}"
    xcrun simctl install "${SIMULATOR}" "${APP_PATH}"
    xcrun simctl install "${SIMULATOR}" "${APP_PATH}"
    fi
    if [ ! -z "$APP_IDENTIFIER" ]
    then
    echo "${SIMULATOR} opening app: ${APP_IDENTIFIER}"
    echo "${SIMULATOR} opening app: ${APP_IDENTIFIER}"
    xcrun simctl launch "${SIMULATOR}" "${APP_IDENTIFIER}"
    fi
    if [ ! -z "$OPEN_URL" ]
    then
    echo "${SIMULATOR} opening url: ${OPEN_URL}"
    echo "${SIMULATOR} opening url: ${OPEN_URL}"
    xcrun simctl openurl "${SIMULATOR}" "${OPEN_URL}"
    fi
  7. patriknyblad revised this gist May 13, 2019. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions xcrun_simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -31,6 +31,10 @@ $ xcrun simctl create iPhone7-my-app com.apple.CoreSimulator.SimDeviceType.iPhon
    ### Shutdown Simulator
    ```
    $ xcrun simctl shutdown booted
    $ xcrun simctl shutdown AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE
    $ xcrun simctl shutdown "iPhone7-my-app"
    $ xcrun simctl shutdown "iPhone XS"
    $ xcrun simctl shutdown all
    ```

    ### Erase contents in Simulator
    @@ -39,6 +43,7 @@ Similar to running a factory restore on your device
    $ xcrun simctl erase AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE
    $ xcrun simctl erase "iPhone7-my-app"
    $ xcrun simctl erase "iPhone XS"
    $ xcrun simctl erase all
    ```

    ### Add media to simulator
  8. patriknyblad renamed this gist May 13, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. patriknyblad revised this gist May 13, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -103,7 +103,7 @@ $ xcrun simctl help
    # Example scripts

    ### Run an app on many simulators
    I personally use this script for running the app I am developing in all possible screen sizes at once to verify that everything works as intended.
    I created and use this script for running the app I am developing in all possible screen sizes at once to verify that everything looks and works as intended.
    ```
    #!/bin/bash
  10. patriknyblad revised this gist May 13, 2019. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -143,8 +143,7 @@ do
    done
    ```

    References:

    ###### References:
    https://medium.com/@ankitkumargupta/ios-simulator-command-line-tricks-ee58054d30f4
    https://medium.com/xcblog/simctl-control-ios-simulators-from-command-line-78b9006a20dc
    https://nshipster.com/simctl/
  11. patriknyblad revised this gist May 13, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -144,6 +144,7 @@ done
    ```

    References:

    https://medium.com/@ankitkumargupta/ios-simulator-command-line-tricks-ee58054d30f4
    https://medium.com/xcblog/simctl-control-ios-simulators-from-command-line-78b9006a20dc
    https://nshipster.com/simctl/
  12. patriknyblad revised this gist May 13, 2019. 1 changed file with 54 additions and 3 deletions.
    57 changes: 54 additions & 3 deletions simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # Managing simulators

    ### List all simulators created
    ```
    $ xcrun simctl list --json
    @@ -20,17 +22,60 @@ $ xcrun simctl boot AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE // UUID Hex string
    $ xcrun simctl boot "iPhone XS Max" // Name of simulator
    ```

    ### Create a simulator with a specific name
    You can name simulators and use them for specific purposes.
    ```
    $ xcrun simctl create iPhone7-my-app com.apple.CoreSimulator.SimDeviceType.iPhone-8 com.apple.CoreSimulator.SimRuntime.iOS-10–3
    ```

    ### Shutdown Simulator
    ```
    $ xcrun simctl shutdown booted
    ```

    ### Erase contents in Simulator
    Similar to running a factory restore on your device
    ```
    $ xcrun simctl erase AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE
    $ xcrun simctl erase "iPhone7-my-app"
    $ xcrun simctl erase "iPhone XS"
    ```

    ### Add media to simulator
    ```
    $ xcrun simctl addmedia booted ./video_01.mp4
    $ xcrun simctl addmedia "iPhone XS" ./video_01.mp4
    ```

    # Working with apps

    ### Install App
    ```
    $ xcrun simctl install booted "./path/to/ios-app.app"
    $ xcrun simctl install "iPhone XS Max" "./path/to/ios-app.app"
    ```

    ### Open App/URL
    ### Uninstall App
    ```
    $ xcrun simctl uninstall booted com.mycompany.myapp
    $ xcrun simctl uninstall "iPhone XS Max" com.mycompany.myapp
    ```

    ### Launch app
    ```
    $ xcrun simctl launch booted com.mycompany.myapp
    $ xcrun simctl launch "iPhone XS Max" com.mycompany.myapp
    ```

    ### Terminate app
    ```
    $ xcrun simctl terminate booted com.mycompany.myapp
    $ xcrun simctl terminate "iPhone XS Max" com.mycompany.myapp
    ```

    ### Open URL
    Can also be used to open an app, if you open the app using a url the first time it will give you an alert asking if you want to navigate to that app.
    ```
    $ xcrun simctl openurl booted https://google.com
    $ xcrun simctl openurl "iPhone XS Max" https://google.com
    @@ -55,8 +100,9 @@ $ xcrun simctl io "iPhone XS Max" screenshot ./simulator-screenshot_001.png
    $ xcrun simctl help
    ```

    # Example scripts

    ### Example script for running an app on many simulators
    ### Run an app on many simulators
    I personally use this script for running the app I am developing in all possible screen sizes at once to verify that everything works as intended.
    ```
    #!/bin/bash
    @@ -95,4 +141,9 @@ do
    fi
    done
    ```
    ```

    References:
    https://medium.com/@ankitkumargupta/ios-simulator-command-line-tricks-ee58054d30f4
    https://medium.com/xcblog/simctl-control-ios-simulators-from-command-line-78b9006a20dc
    https://nshipster.com/simctl/
  13. patriknyblad created this gist May 13, 2019.
    98 changes: 98 additions & 0 deletions simctl_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,98 @@
    ### List all simulators created
    ```
    $ xcrun simctl list --json
    ```

    ### Delete old and unavailable simulators
    ```
    $ xcrun simctl delete unavailable
    ```

    ### Open Simulator.app
    ```
    $ open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/
    ```

    ### Boot specific simulators
    You can find the id/name by listing all simulators `$ xcrun simctl list`.
    ```
    $ xcrun simctl boot AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEE // UUID Hex string
    $ xcrun simctl boot "iPhone XS Max" // Name of simulator
    ```

    ### Install App
    ```
    $ xcrun simctl install booted "./path/to/ios-app.app"
    $ xcrun simctl install "iPhone XS Max" "./path/to/ios-app.app"
    ```

    ### Open App/URL
    ```
    $ xcrun simctl launch booted com.mycompany.myapp
    $ xcrun simctl launch "iPhone XS Max" com.mycompany.myapp
    $ xcrun simctl openurl booted https://google.com
    $ xcrun simctl openurl "iPhone XS Max" https://google.com
    $ xcrun simctl openurl booted myapp://
    $ xcrun simctl openurl "iPhone XS Max" myapp://
    ```

    ### Record simulator video
    ```
    $ xcrun simctl io booted recordVideo — type=mp4 ./simulator-record_001.mp4
    $ xcrun simctl io "iPhone XS Max" recordVideo — type=mp4 ./simulator-record_001.mp4
    ```

    ### Screenshot simulator
    ```
    $ xcrun simctl io booted screenshot ./simulator-screenshot_001.png
    $ xcrun simctl io "iPhone XS Max" screenshot ./simulator-screenshot_001.png
    ```

    ### More help provided using help command
    ```
    $ xcrun simctl help
    ```


    ### Example script for running an app on many simulators
    I personally use this script for running the app I am developing in all possible screen sizes at once to verify that everything works as intended.
    ```
    #!/bin/bash
    # List of simulators: `$ xcrun simctl list`
    SIMULATORS=("iPhone SE" "iPhone 8" "iPhone 8 Plus" "iPhone XS" "iPhone XS Max" "iPhone XR")
    # Comment or remove variables to skip a step
    APP_PATH="/path/to/my/build/directory/when/running/a/build/in/xcode/app.app"
    APP_IDENTIFIER="com.mycompany.myapp" # Identifier from info.plist
    OPEN_URL="myapp://some/page/in/app" # Deep linking
    echo "Running on ${#SIMULATORS[*]} simulators."
    for index in ${!SIMULATORS[*]}
    do
    SIMULATOR=${SIMULATORS[$index]}
    echo "Booting ${SIMULATOR}..."
    xcrun simctl boot "${SIMULATOR}"
    if [ ! -z "$APP_PATH" ]
    then
    echo "${SIMULATOR} installing: ${APP_PATH##*/}"
    xcrun simctl install "${SIMULATOR}" "${APP_PATH}"
    fi
    if [ ! -z "$APP_IDENTIFIER" ]
    then
    echo "${SIMULATOR} opening app: ${APP_IDENTIFIER}"
    xcrun simctl launch "${SIMULATOR}" "${APP_IDENTIFIER}"
    fi
    if [ ! -z "$OPEN_URL" ]
    then
    echo "${SIMULATOR} opening url: ${OPEN_URL}"
    xcrun simctl openurl "${SIMULATOR}" "${OPEN_URL}"
    fi
    done
    ```