Skip to content

πŸš€ Goodies for Xcode IDE - templates, keyboard shortcuts and tips for quick iOS development

License

Notifications You must be signed in to change notification settings

josefdolezal/xcode-goodies

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Xcode goodies

Content

Templates

By default, Xcode supports only Apple MVC templates. This leads to terrible inconsistency in app layers when you use different architecture. Also, a lot of boilerplate code must be deleted, some must be added. Because of that, I decided to create MVVM friendly templates. The MVVM style is heavily inspired by Kickstarter's iOS App. That means, all View Models are composed from inputs and outputs and implements Type protocol. All Controllers created with MVVM template requires ViewModel class.

All templates are separated in to sections with MARK: - comments. This creates fine document outline when you press ctrl ^ + 6.

Currently, this repository contains templates for:

Installation

Templates are located in user's Library folder where Xcode keeps custom configuration. To install templates, just copy them to correct location. However, better way to stay up-to date with latest repo version is to create symbolic link for whole templates folder.

First of all, clone this repository:

$ git clone https://github.com/josefdolezal/xcode-goodies

Once the repository is clonned, create the symbolic link:

$ TEMPLATES_GROUP="<My templates>"
$ cd xcode-goodies # Switch to the repository
$ ln -s "$PWD" ~/Library/Developer/Xcode/Templates/"$TEMPLATES_GROUP"

Be sure you replaced <My templates> placeholder with group name you want to see in Xcode. If everything went right, you should see new section at the bottom of the list when you press cmd ⌘ + n.

Snippets

Similary as templates, Xcode supports custom code snippets. A lot of standard snippets are included in base Xcode installation, however it's not enough! Do you remember this few lines of code you have to write whenever you want to disable Swiftlint here and then enable it somewhere else again? Does it take you at least second try to write correct syntax of Localizable.strings? Oh, and did I mention the Realm API which is not suggested by Xcode because it's implemented with static methods? Custom snippets are here for rescue! See the list below and choose your favorite.

List of custom snippets

ReactiveSwift & ReactiveCocoa

Realm

Swiftlint

Localizable strings file

Installation

The installation is alson done with symlinks, but snippets does not support subfolders. Snippets must be linked separately:

$ cd xcode-goodies/snippets # Switch to the repository
$ ln -s "$PWD"/*.codesnippet ~/Library/Developer/Xcode/UserData/CodeSnippet

Note that if you have your own snippets already, there may be some name conflicts during installation. In that case, rename the conflicted files (your or these in repository) and run the installation script again.

To see the effect, restart the Xcode.

Keyboard shortcuts

Scheme / Target / Product

Effect Shortcut
Switch build scheme ctrl ^ + cmd ⌘ + [ or ctrl ^ + cmd ⌘ + ]
Switch product destination (simulator) ctrl ^ + alt βŽ‡ + cmd ⌘ + [ or ctrl ^ + alt βŽ‡ + cmd ⌘ + ]

Editor focus

Effect Shortcut
Move focus to different editor cmd ⌘ + j
Open assistant editor * cmd ⌘ + alt βŽ‡ + enter ↩
Close assistant editor cmd ⌘ + enter ↩
Switch tab cmd ⌘ + shift ⬆ + [ or cmd ⌘ + shift ⬆ + ]
Open new tab cmd ⌘ + t

* Don't forget to check Use Focused Editor in Xcode Navigation preferences, or each new file will be opened in the standard editor every time.

Source code editing

Effect Shortcut
Open quickly cmd ⌘ + shift ⬆ + o
Show completions ctrl ^ + space or esc*
Re-indent selection ctrl ^ + i

* Must be turned on explicitly in Text Editing under Code completions options.

Editor navigation

Effect Shortcut
Move to the beginning of the line cmd ⌘ + ←
Move to the end of the line cmd ⌘ + ➑
Move to the beginning of the word alt βŽ‡ + ←
Move to the end of the word alt βŽ‡ + ➑
File outline ctrl ^ + 6

Line navigation may be also combined with backspace β¬… to achieve ultimate deletion combos.

Editor commands

Effect Shortcut
Build target cmd ⌘ + b
Run product cmd ⌘ + r
Run all tests cmd ⌘ + r
Run current test cmd ⌘ + ctrl ^ + alt βŽ‡ + u
Clean project cmd ⌘ + shift ⬆ + k
Clean build folder cmd ⌘ + alt βŽ‡ + shift ⬆ + k

Editor layout

Effect Shortcut
Toggle console cmd ⌘ + shift ⬆ + y
Toggle navigator cmd ⌘ + 0
Toggle utilities cmd ⌘ + alt βŽ‡ + 0

About

πŸš€ Goodies for Xcode IDE - templates, keyboard shortcuts and tips for quick iOS development

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published