7 Useful Tips and Tricks for Xcode

Göktuğ Gümüş
Dec 29, 2019 · 6 min read

In this article, I am going to talk about some of the tricks and shortcuts that help me in Xcode. I hope they help you, too.

The original article is written in Turkish. Therefore some of screenshots may have Turkish words on it.

1. Searching using RegEx

I always love using RegEx while searching. It helps me find what I want easily. So, how do we use this feature?

Steps

  1. Select File Navigator from the menu to the left in Xcode.
  2. Switch the Text preference to Regular Expression.
  3. Now, you can search what you want using RegEx.

You can also make use of online websites, such as https://regex101.com, to improve your RegEx use and to check the validness of RegEx that you wrote.


2. Opening A Project from Terminal with Xcode

You can open Xcode projects using Terminal. If you run the xed. command in the main index of any Xcode project, it will open the project directly.

If it is a workspace project, it will automatically open the .xcworkspace file.


3. Viewing the Interface of Class and Struct Files

If you want to check quickly the parameters and methods used in the object, the following method can be useful for you.

Steps

  1. Open the Class or Struct file.
  2. Use the ⌘⌃↑ (Cmd+Ctrl+↑) shortcut.
  3. Xcode will automatically create the interface of the object.

4. Quick Access to the Methods and Variables in the Object

You can get access to any method or parameter in the object you want to find using the Jump Bar.

Steps

  1. Use the ⌃6 (Ctrl + 6) shortcut while in the Class or struct file.
  2. It will open the Jump Bar window for the list of methods and parameters in the object.
  3. You can choose the method or parameter you want to get access directly or you can filter the list by typing in order to get access faster.

5. Watching Variables while Debugging

You have the opportunity to watch the certain status of applications while debugging with the breakpoint feature of Xcode. So far so good, however, when you want to watch the change in the variable you want to monitor or to see which line causes the change, you can use the following method.

Steps

  1. Put breakpoint in the place where the variable you want to watch is created first.
  2. Right-click on the variable you want to watch in the Debug Area at the bottom-left when the running of code for the breakpoint is stopped after you run the project.
  3. Continue to run the program after choosing Watch “variable name”.
  4. Now, when there is any change in the variable you watch, Xcode will show you the line that causes the change.

6. Using the Assistant Editor More Effectively

I prefer using the Assistant Editor (Split Screen) while working on two files at the same time. If you also prefer working like this, you must have needed to change the file in the editor at some point. In order to change the file in the secondary editor, hold down the ⌥ (Option / Alt) button and click on the file you want to open from Project Navigator to the left. In addition to this method, there is also another way to do this.

Steps

  1. Go to Preferences window in Xcode.
  2. Go to Navigation tab from the top menu.
  3. Select “Uses Focused Editor” for the Navigation feature under the Navigation tab.
  4. Now, while using Assistant Editor, the file you select from the Project Navigator will open in wherever your cursor is.

7. Quick Access to Any File or Line in the Project

In order to access quickly to any file in the project, you can open the Quickly box by the ⌘⇧O (Cmd+Shift+O) shortcut and do a search. Therefore, you can access any file without wasting time. So far so good, however, when you want to go to a specific line inside the file you search for, you can use the following method.

Steps

  1. Open the Quickly box using the ⌘⇧O (Cmd+Shift+O) shortcut.
  2. Type the name of the file you want to access until it shows up on the list.
  3. Add :linenumber to the end of the search in order to find the line you want to access. Example: log:17
  4. When you click on the file you want to get access from the list on the screen, Xcode will take you to the respective line of the file.

BONUS: Quick Access to an Open File in Project Navigator

You got access to the file you searched for with the method above, but now, you want to see the file in Project Navigator. For this, you can use the following method.

Steps

  1. Use the ⌘⇧J (Cmd + Shift + J) shortcut while the file is open.
  2. You can see the relevant file in Project Navigator.

This is all I have compiled for this article. See you in the second part! If you liked this article, don’t forget to like and subscribe to me.

Flawless iOS

🍏 Community around iOS development, mobile design, and marketing

Göktuğ Gümüş

Written by

Sr. iOS Developer at Scoutium — goktuggumus.com

Flawless iOS

🍏 Community around iOS development, mobile design, and marketing

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade