Breaking news! I just launched Coparrot, a no-install and no-configuration mock server for mobile and web developers, on Product Hunt!
Please check it out and give it some love ❤️!
May 31, 2021 in articles
In this article I will share some tips and tricks to use Xcode that I discussed with fellow Indonesian iOS developers at the last session of Belajar Swift Bareng Mingguan.
cmd+shift+o keyboard shortcut to quickly open files. Once the search field appears, you can start typing the name of the file that you want to open. Since it uses fuzzy search, you don’t even need to type the exact filename. To open the file, you can press Enter key, or
option+Enter to open the file in the Assistant Editor.
cmd+option+Enter to quickly hide and show the SwiftUI Previews.
Xcode pauses the SwiftUI Preview from time to time. Use
cmd+option+P to quickly resume the SwiftUI Previews.
cmd+shift+J to quickly show the file in the project navigator.
cmd+L to quickly go to a certain line.
cmd+shift+y to quickly show and hide the Debug area.
Assign a keyboard shortcut to quickly show the document items. In my case, I use
cmd+§ because I’ve never used it ever.
cmd+option+right arrow and
cmd+option+left arrow to quickly fold and unfold codes.
cmd+< to quickly open the Edit Scheme window.
ctrl+i to quickly fix the identation of your code.
cmd+option+/ to quickly add documentation to a function, class, etc. You can then use Markdown in the documentation.
Assign any keyboard shortcut to quickly open the project in Terminal. In my case, I use
cmd+P because the default it to print and let’s be honest, we’ll never print our source code.
To be able to do this, you need to create a small shell script with the following content:
#!/bin/bash open -a Terminal "`pwd`"
Then add a custom behaviour in the Xcode Preferences.
-NSDoubleLocalizedStrings YES to the
Arguments Passed On Launch in the scheme to double the texts shown in your app.
Quickly edit multiple lines by pressing
shift+control+option when clicking the line.
cmd+option+E to quickly select next occurrences of selected text and
cmd+control+E to select all occurrences in the current scope.
And just for fun, you can make your Mac say a custom message when a build succeeded or failed. It can be pretty fun especially if you’re bored working alone from home 🤣
To be able to do this, you need to create a small shell script as follows.
#!/bin/sh say -v Serena "Great job! Build succeeded!"
You can change the voice by replacing
Serena in the script above with other voices. You can find the list of available voices by going to System Preferences -> Dock & Menu Bar -> Clock. Check the
Announce the time: then click the
Articles, drawings, and codes by Nico Prananta, a software developer (iOS and web) and digital artist (for fun!) in Zürich, Switzerland. I'm on Twitter.
For Indonesian iOS Developers! Gabung yuk tiap hari Sabtu jam 16:00 WIB di Belajar Bareng Swift Mingguan bareng temen-temen iOS developer di Swift Study Group Indonesia.