Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tahirmt/82316f9fb7e53567b1e81403415039ec to your computer and use it in GitHub Desktop.

Select an option

Save tahirmt/82316f9fb7e53567b1e81403415039ec to your computer and use it in GitHub Desktop.

Revisions

  1. @danielmartin danielmartin revised this gist Nov 16, 2019. No changes.
  2. @danielmartin danielmartin revised this gist Nov 16, 2019. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions BetterXcodeJumpToCounterpartSwift.org
    Original file line number Diff line number Diff line change
    @@ -16,5 +16,11 @@ now:

    Ctrl+Cmd+Up and Ctrl+Cmd+Down will cycle those files and their interfaces generated by SourceKit.

    If you want to revert the change, simply run this in a terminal and restart Xcode:

    #+BEGIN_SRC sh
    defaults delete com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes
    #+END_SRC

    This configuration used to work for the Objective-C family of languages, but recent versions of Xcode seem to have added support for
    Swift too.
  3. @danielmartin danielmartin created this gist Nov 16, 2019.
    20 changes: 20 additions & 0 deletions BetterXcodeJumpToCounterpartSwift.org
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to
    jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

    You can do this in recent versions of Xcode by setting a configuration default.

    From a terminal, just type this command and press Enter:

    #+BEGIN_SRC sh
    defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"
    #+END_SRC

    Restart Xcode and navigate to one of your Swift model files. You'll see counterparts more tailored to your project architecture
    now:

    [[https://user-images.githubusercontent.com/1573717/68997038-34190300-08a2-11ea-8e40-d74adc3a02db.png]]

    Ctrl+Cmd+Up and Ctrl+Cmd+Down will cycle those files and their interfaces generated by SourceKit.

    This configuration used to work for the Objective-C family of languages, but recent versions of Xcode seem to have added support for
    Swift too.