Week 7: Handy Xcode Features to Save Us Time

Dylan Chen
May 11 · 4 min read
Photo by Sam Dan Truong on Unsplash

Hi iOS Developers,

Building apps is very time-consuming. Knowing the tool to use is critical. Xcode is a great tool that has a lot of built-in features that help developers save lots of time. Today, we are going to talk about some of the great Xcode features you might not be aware of. Let’s get started!

Snippets

Let’s take a look at this example.

We have two protocols: Identifiable and Updatable. And we require all ViewModels to conform to these two protocols. Imagine that we need to create dozens of ViewModels . Typing the code that many times would be very time-consuming and inefficient.

Here are the four steps needed to create this snippet:

class CustomViewModel: Identifiable, Updatable {
var id: String {
return String(describing: type(of: self))
}
func update() {
print("Update the model")
}
}

2. Add placeholders

To add a placeholder, we can add <# placeholder #>

3. Create a snippet

Select the template and right-click on it. Choose Create Code Snippet .

4. Fill out the snippet form

To use it, type out the Completion, and can see the snippet in the auto-complete.

Fix All Issues

What if there are dozens of suggestions, and we decide we want to accept all of them.

TThe shortcut for this is: ⌃⌥⌘F or Ctrl + Alt + Cmd + F

Notes: Fix All Issues doesn’t work if there is more than one suggestion for a single error.

Rename

Cmd + Click on the variable. Then on the dropdown menu, select Rename. This handy shortcut allows us to rename all the instances that are referred to by that variable.

Documentation

To generate a documentation template, move the cursor to just above the function, and then hit Alt + Cmd + /. We can see that the template already takes the parameter and the return type. All we have to do is to fill out the placeholder.

Code Folding Ribbon

To enable this feature, open, open preferences -> Text Editing -> Display and check the Code Folding Ribbon checkbox.

This is all I have for Week 7. Hope you found this information useful and time-saving. As usual, I’ll be posting another story about iOS development next week. See you then!

Medium Claps — Made in Flinto by Thuy Gia Nguyen on Dribbble

Please clap if you enjoyed this story. Follow me. I’ll see you in subsequent stories :)

YOU MAY ALSO BE INTERESTED IN:

Geek Culture

Proud to geek out. Follow to join our +500K monthly readers.

Dylan Chen

Written by

iOS Engineer at Lunchbox Technologies. Buy me a coffee at: https://www.buymeacoffee.com/dylancfe15

Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).

Dylan Chen

Written by

iOS Engineer at Lunchbox Technologies. Buy me a coffee at: https://www.buymeacoffee.com/dylancfe15

Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store