Skip to content

Instantly share code, notes, and snippets.

@leviathan
Last active August 29, 2025 19:44
Show Gist options
  • Select an option

  • Save leviathan/0c806022cd83d0a51a15c92b6b53db49 to your computer and use it in GitHub Desktop.

Select an option

Save leviathan/0c806022cd83d0a51a15c92b6b53db49 to your computer and use it in GitHub Desktop.

Revisions

  1. leviathan revised this gist Mar 22, 2022. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -31,6 +31,11 @@ The builds duration appears after a build, alongside with the “Succeeded” me

    ![activity-viewer](https://user-images.githubusercontent.com/115210/159497318-96af1ad8-de0e-4c73-9e2e-a8c617f86de8.png)

    #### Xcode build timing summary

    Run Xcode Build Timing Summary to get build time insights and find bottlenecks - run it via: `Product => Perform Action => Build With Timing Summary`.

    ![timing-summary](https://user-images.githubusercontent.com/115210/159498027-a777219f-a018-4ade-8e71-10770f97419f.png)


    ### Swift Package Manager
  2. leviathan revised this gist Mar 22, 2022. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -14,11 +14,19 @@ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version // Check X

    ### Measuring Xcode build time

    #### Xcode build report

    We can get the build time easily via Xcode. It keeps track of all your builds by default and you can examine the times and logs from the Report Navigator.

    ![build-report](https://user-images.githubusercontent.com/115210/159497658-073b78b8-2e66-4a1b-ad61-d1a93b485cc8.png)

    Duration appears in the activity viewer after a build, alongside the "Succeeded" message.
    If you are running the app, the status will be replaced by the running status before you can see the duration.
    ```

    ```terminal
    $> defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES
    ```

    The builds duration appears after a build, alongside with the “Succeeded” message.

    ![activity-viewer](https://user-images.githubusercontent.com/115210/159497318-96af1ad8-de0e-4c73-9e2e-a8c617f86de8.png)
  3. leviathan revised this gist Mar 22, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,8 @@ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version // Check X

    ## Xcode tips

    ### Measuring Xcode build time

    Duration appears in the activity viewer after a build, alongside the "Succeeded" message.
    If you are running the app, the status will be replaced by the running status before you can see the duration.
    ```
  4. leviathan revised this gist Mar 22, 2022. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,7 @@ $> defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES
    ```
    The builds duration appears after a build, alongside with the “Succeeded” message.

    ![activity-viewer](https://user-images.githubusercontent.com/115210/159497318-96af1ad8-de0e-4c73-9e2e-a8c617f86de8.png)



  5. leviathan revised this gist Mar 22, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -20,6 +20,8 @@ $> defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES
    The builds duration appears after a build, alongside with the “Succeeded” message.




    ### Swift Package Manager

    1. `~/Library/Caches/org.swift.swiftpm/repositories` => Delete package folder and lock file
  6. leviathan revised this gist Mar 22, 2022. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,8 @@ If you are running the app, the status will be replaced by the running status be
    ```
    $> defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES
    ```
    The builds duration appears after a build, alongside with the “Succeeded” message.


    ### Swift Package Manager

  7. leviathan revised this gist Mar 22, 2022. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,9 @@ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version // Check X

    Duration appears in the activity viewer after a build, alongside the "Succeeded" message.
    If you are running the app, the status will be replaced by the running status before you can see the duration.
    `$> defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES`
    ```
    $> defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES
    ```

    ### Swift Package Manager

  8. leviathan revised this gist Mar 22, 2022. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,12 @@ pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version // Check X

    ## MacOSX Xcode

    ## Xcode tips

    Duration appears in the activity viewer after a build, alongside the "Succeeded" message.
    If you are running the app, the status will be replaced by the running status before you can see the duration.
    `$> defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES`

    ### Swift Package Manager

    1. `~/Library/Caches/org.swift.swiftpm/repositories` => Delete package folder and lock file
  9. leviathan revised this gist Oct 20, 2021. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,13 @@ swift build --version
    pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version // Check Xcode Command-Line-Tools Version
    ```

    ## MacOSX Xcode

    ### Swift Package Manager

    1. `~/Library/Caches/org.swift.swiftpm/repositories` => Delete package folder and lock file
    2. in Xcode, run `File -> Swift Packages -> Reset Package Caches`

    ## xcode-select

    **version**
  10. leviathan revised this gist Sep 29, 2021. 1 changed file with 32 additions and 1 deletion.
    33 changes: 32 additions & 1 deletion xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -103,4 +103,35 @@ Get the list in structured format:
    $ xcrun simctl list --json
    ```

    Reference: https://nshipster.com/simctl/
    Reference: https://nshipster.com/simctl/

    ## Custom toolchain from the command line

    When using `xcodebuild` or ie. `Fastlane` to build your project, it will use the default swift toolchain (the one from the currently selected Xcode).

    You can check currently selected toolchain with this command:
    ```
    $> swift --version
    Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
    Target: x86_64-apple-darwin19.3.0
    ```

    To use the alternative toolchain you can run `xcrun` and `xcodebuild` with a `-toolchain` flag like this:
    ```
    xcodebuild -toolchain NAME
    xcrun --toolchain NAME
    ```
    where `NAME` is either an identifier or name of the toolchain, ie. `xcodebuild --toolchain swift`.

    You could also export it to your current terminal session with a command:
    ```
    $> export TOOLCHAINS=swift
    $> export TOOLCHAINS=org.swift.51220191130a // /Library/Developer/Toolchains/swift-5.1.2-RELEASE.xctoolchain/Info.plist => CFBundleIdentifier
    ```

    ## Carthage

    Run carthage with a specific swift toolchain:
    ```
    carthage update --toolchain org.swift.402017072a
    ```
  11. leviathan revised this gist Sep 29, 2021. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -28,8 +28,7 @@ foo@bar:~$ xcode-select -p
    $ xcode-select -s/--switch /Library/Developer/CommandLineTools/
    ```

    h4. Re-Install Command line tools

    **Re-Install Command line tools**
    => This will download and install the lastest CLT version from Apple and install it.
    ```console
    $> sudo rm -rf /Library/Developer/CommandLineTools
  12. leviathan revised this gist Sep 29, 2021. 1 changed file with 33 additions and 2 deletions.
    35 changes: 33 additions & 2 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -8,17 +8,48 @@ swift build --version
    pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version // Check Xcode Command-Line-Tools Version
    ```

    ## xcode-select

    **version**
    ```console
    foo@bar:~$ xcodebuild -version
    Xcode 10.1
    Build version 10B61
    ```

    **Check the currently selected directory.**
    ```console
    foo@bar:~$ xcode-select -p
    /Applications/Xcode_10.1.app/Contents/Developer
    ```

    **Select Command line tools:**
    ```console
    $ xcode-select -s/--switch /Library/Developer/CommandLineTools/
    ```

    h4. Re-Install Command line tools

    => This will download and install the lastest CLT version from Apple and install it.
    ```console
    $> sudo rm -rf /Library/Developer/CommandLineTools
    $> xcode-select --install
    ```

    => If older CLT version is needed, then uninstall current version & download PKG from [Apple Downloads](https://developer.apple.com/download/all/)


    ## xcrun

    Get help
    **Get help**
    ```
    $ xcrun simctl help
    usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...
    simctl help [subcommand]
    Command line utility to control the Simulator
    ```

    Run the list subcommand to get a list of the available runtimes, device types, devices, and device pairs:
    **Run the list subcommand to get a list of the available runtimes, device types, devices, and device pairs:**
    ```
    $ xcrun simctl list
    -- iOS 12.1 --
  13. leviathan revised this gist Aug 5, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@ xcode-select --print-path
    xcodebuild -version
    swift --version
    swift build --version
    pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version // Check Xcode Command-Line-Tools Version
    ```

    ## xcrun
  14. leviathan revised this gist Jul 21, 2021. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,12 @@
    ## Environment Info

    ```
    xcode-select --print-path
    xcodebuild -version
    swift --version
    swift build --version
    ```

    ## xcrun

    Get help
  15. leviathan revised this gist Jul 19, 2021. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -46,6 +46,9 @@ $ xcrun simctl delete unavailable

    ```
    $ xcrun simctl openurl booted "http://google.com"
    // open app url
    $ xcrun simctl openurl booted "ios-cobi://bike.cobi/app?state=w4BZrykXl7..."
    ```

    // Print the UUID of the device in your simulator
  16. leviathan revised this gist Jan 20, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    Get help
    ```
    xcrun simctl help
    $ xcrun simctl help
    usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...
    simctl help [subcommand]
    Command line utility to control the Simulator
  17. leviathan revised this gist Jan 20, 2020. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,13 @@
    ## xcrun

    Get help
    ```
    xcrun simctl help
    usage: simctl [--set <path>] [--profiles <path>] <subcommand> ...
    simctl help [subcommand]
    Command line utility to control the Simulator
    ```

    Run the list subcommand to get a list of the available runtimes, device types, devices, and device pairs:
    ```
    $ xcrun simctl list
  18. leviathan revised this gist Jan 20, 2020. 1 changed file with 31 additions and 0 deletions.
    31 changes: 31 additions & 0 deletions xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,35 @@
    ## xcrun

    Run the list subcommand to get a list of the available runtimes, device types, devices, and device pairs:
    ```
    $ xcrun simctl list
    -- iOS 12.1 --
    iPhone 5s (CC96B643-067E-41D5-B497-1AFD7B3D0A13) (Shutdown)
    iPhone 6 (7A27C0B9-411A-4BCD-8A67-68F00DF39C1A) (Shutdown)
    iPhone 6 Plus (A5918644-8D46-4C67-B21E-68EA25997F91) (Shutdown)
    iPhone 6s (1AB5A4EB-2434-42E4-9D2C-42E479CE8BDC) (Shutdown)
    ```

    One such subcommand is `boot`, which starts up the specified device, making it available for interaction:

    ```
    $ xcrun simctl boot $UUID
    ```

    ```
    $ xcrun simctl shutdown $UUID
    $ xcrun simctl erase $UUID
    ```

    // Removes old simulators, which xcode no longer uses

    ```
    $ xcrun simctl delete unavailable
    ```

    ### Opening URLs in Simulator

    // xcrun allows you to invoke developer tools from the terminal.
    // In this case simctl, which is a command line utility to control the iOS Simulator.
    // simctl has the subcommand: openurl to open URLs in a given simulator
    @@ -20,5 +44,12 @@ $ xcrun simctl openurl booted "http://google.com"

    ```
    $ xcrun simctl list | egrep '(Booted)'
    iPhone X (9FED67A2-3D0A-4C9C-88AC-28A9CCA44C60) (Booted)
    ```

    Get the list in structured format:
    ```
    $ xcrun simctl list --json
    ```

    Reference: https://nshipster.com/simctl/
  19. leviathan revised this gist Jan 20, 2020. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,23 @@
    ## xcrun

    // Removes old simulators, which xcode no longer uses

    ```
    $ xcrun simctl delete unavailable
    ```

    // xcrun allows you to invoke developer tools from the terminal.
    // In this case simctl, which is a command line utility to control the iOS Simulator.
    // simctl has the subcommand: openurl to open URLs in a given simulator
    // most of the cases you would like to open on the current booted device, so you add
    // most of the cases you would like to open on the current booted device, so you add
    // the flag booted or type the simulator id.

    ```
    $ xcrun simctl openurl booted "http://google.com"
    ```

    // Print the UUID of the device in your simulator

    ```
    $ xcrun simctl list | egrep '(Booted)'
    ```
  20. leviathan renamed this gist Jan 20, 2020. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions xcode-utils → xcode-utils.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,19 @@
    // Removes old simulators, which xcode no longer uses
    ```
    $ xcrun simctl delete unavailable
    ```

    // xcrun allows you to invoke developer tools from the terminal.
    // In this case simctl, which is a command line utility to control the iOS Simulator.
    // simctl has the subcommand: openurl to open URLs in a given simulator
    // most of the cases you would like to open on the current booted device, so you add
    // the flag booted or type the simulator id.
    ```
    $ xcrun simctl openurl booted "http://google.com"
    ```

    // Print the UUID of the device in your simulator
    ```
    $ xcrun simctl list | egrep '(Booted)'
    ```

  21. leviathan revised this gist Nov 24, 2019. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions xcode-utils
    Original file line number Diff line number Diff line change
    @@ -8,3 +8,6 @@ $ xcrun simctl delete unavailable
    // the flag booted or type the simulator id.
    $ xcrun simctl openurl booted "http://google.com"

    // Print the UUID of the device in your simulator
    $ xcrun simctl list | egrep '(Booted)'

  22. leviathan revised this gist Apr 17, 2018. No changes.
  23. leviathan revised this gist Apr 17, 2018. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions xcode-utils
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,10 @@
    // Removes old simulators, which xcode no longer uses
    $ xcrun simctl delete unavailable

    // Open the provided URL in the currently booted simulator
    $ xcrun simctl openurl booted http://google.com
    // xcrun allows you to invoke developer tools from the terminal.
    // In this case simctl, which is a command line utility to control the iOS Simulator.
    // simctl has the subcommand: openurl to open URLs in a given simulator
    // most of the cases you would like to open on the current booted device, so you add
    // the flag booted or type the simulator id.
    $ xcrun simctl openurl booted "http://google.com"

  24. leviathan revised this gist Apr 16, 2018. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion xcode-utils
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,5 @@
    #### removes old simulators, which xcode no longer uses
    // Removes old simulators, which xcode no longer uses
    $ xcrun simctl delete unavailable

    // Open the provided URL in the currently booted simulator
    $ xcrun simctl openurl booted http://google.com
  25. leviathan revised this gist Apr 16, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xcode-utils
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    // removes old simulators, which xcode no longer uses
    #### removes old simulators, which xcode no longer uses
    $ xcrun simctl delete unavailable
  26. leviathan renamed this gist Nov 3, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  27. leviathan renamed this gist Nov 3, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  28. leviathan renamed this gist Nov 3, 2017. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions xcode → xcode-utils.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,2 @@
    ```
    // removes old simulators, which xcode no longer uses
    $ xcrun simctl delete unavailable
    ```
  29. leviathan revised this gist Nov 3, 2017. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion xcode
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,4 @@
    ```
    // removes old simulators, which xcode no longer uses
    $ xcrun simctl delete unavailable
    $ xcrun simctl delete unavailable
    ```
  30. leviathan created this gist Nov 3, 2017.
    2 changes: 2 additions & 0 deletions xcode
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    // removes old simulators, which xcode no longer uses
    $ xcrun simctl delete unavailable