Xcode Setup
Using Xcode the right way is as important as sitting on a comfortable chair to endure long hours of coding. This is my personal note to remind me on what to do when I need to do a fresh Xcode install, and its shortcut.
Get rid of those trailing whitespace
Method 1: Xcode preferences
This is best described by John Sundell’s tweet on why you should enable this option. Very useful if you need to entertain linting tools such as SwiftLint or Codacy.
There's a setting in Xcode to automatically trim whitespace from empty lines. Super useful when working on projects that use linting tools (like SwiftLint) which generates warnings for this kind of whitespace 👍
— John Sundell (@johnsundell) January 13, 2018
Have a great weekend everyone! 😊 pic.twitter.com/NLPBG0Osog
Method 2: command line
However, if by chance, I forgot to check this option, here’s the magic line that should clean up thos extras, effortlessly. From the root source directory: find . -name '*.swift' | xargs -I{} sed -i '' 's/[[:space:]]*$//g' {}
. Be sure to commit everything first before running that!
Source: here
Method 3: git
I haven’t actually tested this but another tweet reply recommends to add the following configurations in ~/.gitconfig
:
[core]
whitespace = trailing-space,space-before-tab
[apply]
whitespace = fix
Make your eyes comfortable
Todate, my favorite Xcode theme is still this WWDC17, which you can download from here
My favorite Xcode shortcuts
Shortcuts are habit that needs to be developed as I need to be faster.
⌘ + Shift + O
and start typing the file or function or class name. No doubt, this is faster than browsing through the Project Navigator especially for big projects.⌘ + Shift + J
will immediately focus the file that you’re editing on the Project Navigator. Very useful because usually view controller and view model are close to each other⌘ + Shift + 0
to hide the entire Inspector on the right⌘ + 0
to hide the entire Navigator on the left⌘ + Shift + Y
to hide the entire Debugging, bottom area⌘ + Shift + F
to start searching any text across filesControl + 6
and start typing any function or variable name and it will point you right where it is. This is very useful for a long file! plus, it makes you look pro haha⌘ + r
, obviously to run the project⌘ + Shift + option + K
, to super clean the project or clear derived data (cleaner than⌘ + Shift + K
)⌘ + b
, the fastest way to build the project⌘ + .
, the fastest way to stop any runs- Add shortcut
dd
to delete line from Xcode’s keyboard binding