Skip to content

Instantly share code, notes, and snippets.

@cleonps
Last active February 22, 2023 00:44
Show Gist options
  • Save cleonps/e295939d13768b32b0f3990d3f3a0c44 to your computer and use it in GitHub Desktop.
Save cleonps/e295939d13768b32b0f3990d3f3a0c44 to your computer and use it in GitHub Desktop.
XCode Tips

Remove all cached data and simulators data

Remove all data from all simulators

  • Close XCode and simulators
  • Open terminal:
    xcrun simctl erase all

Remove all data from specific simulator

  • Close XCode and simulators
  • Open terminal and list devices, then replace device_ID with the corresponding ID:
    xcrun simctl list
    xcrun simctl erase device_ID

Remove all cache from SwiftUI Previews

  • Close XCode and simulators
  • Open terminal:
    xcrun simctl --set previews delete all

Remove some cached files that the "Clean Build Folder" option can't remove (From Finder: shift+command+G)

  • Delete the folder DerivedData OR all contents:
    ~/Library/Developer/XCode/DerivedData

Share XCode Snippets via iCloud

  • If you already have some XCode Snippets, move the "CodeSnippets" folder into your iCloud. It could be at the iCloud's root directory or at any directory.
  • Then create a symbolic link from the folder "CodeSnippets" to your "~/Library/Developer/Xcode/UserData" folder. To copy the full path to your "CodeSnippets" folder, just drag it into the terminal.
    ln -s "full-path-to/CodeSnippets" ~/Library/Developer/Xcode/UserData
  • If you need your snippets from another machine, just create the symbolic link to your iCloud again

XCode Project Build Time

  • From terminal
    defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES

Exception Breakpoint

Create an exception breakpoint to show the last line of executed code before an internal framework/library crashes.

  • Go to "Breakpoint Navigator"
  • Click on "Plus Button" at the bottom
  • Edit Breakpoint
  • Add Action
  • Debugger Command
    po $arg1

CocoaPods Commands

CocoaPods Installation

  • Only needed the first time
    sudo gem install cocoapods

Pods installation

  • Go to root project folder from terminal
    pod init
  • Edit the Podfile (I'm using Sublime Text, replace for your text editor)
    open -a "Sublime Text" Podfile
  • Add your pods and save the file, then install pods from terminal
    pod install

Update ALL Pods

  • Go to root project folder from terminal
    pod update

Update ONLY specific Pod

  • Go to root project folder from terminal (Replace PodName)
    pod update PodName

List ALL outdated Pods

  • Go to root project folder from terminal
    pod outdated

Hide ALL Pod Warnings

  • Open Podfile and add
    inhibit_all_warnings!

Hide ONLY specific Pod Warnings

  • Open Podfile and add (Replace PodName)
    pod 'PodName', : inhibit_warnings => true

More on INSTALLING SPECIFIC VERSIONS

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