Search

Xcode tricks and tips



Writing code is fun but not an easy task. While writing code in Objective-C or Swift, if we could also perform some Xcode tasks swiftly, it would be so awesome.

Here I am listing some of the Xcode shortcuts which would definitely come handy. Or, you could still learn them if you want to project yourself as a pro among your colleagues.

  1. Tagging your code is an awesome way to find a section or a part of code. You must try using special tags like "//MARK, //TODO and //FIXME". These tags will create a special section separator in your code.

  2. Snippets. Did you know that you could save a code snippet in the snippets library so you can simply reuse them in your new projects? Copy-Paste is too old now. Isn't it?

  3. If you want to open the drop-down with all the variables and method names, simply press ^ + 6. Also, when the drop-down is open you can simply start typing the method or variable name you wanted to go to.

  4. If you want to add a placeholder field in any part of your code, just type <#placeholder#>.

  5. Did you know that you can create a custom color in the assets catalog and use it in code or in the storyboard or Interface Builder directly? To do that, just right-click the assets folder and choose "New Color Set" and then adjust the RGB sliders to create your color. You can also name it and call it in the code as well by UIColor(named: "Color").

  6. Press ⌘ + ⇧ + [ or ] to navigate between the tabs.

  7. You are probably already aware of what ⌘ + F does. Now, if you press ⌘ + ⌥ + F, you'll have the find and replace option available.

  8. If you hold the key and drag over with the mouse to select a section of your code, you can edit all the selected lines simultaneously.

  9. Open Quickly. Use the shortcut ⇧ + ⌘ + O to open any file or method in your project. If you add a colon ":", it will let you specify a particular line number.

  10. Open your debugging window by using the shortcut ⌘ + ⇧ + Y.

  11. Open the left navigator panel by pressing ⌘ + 0.

  12. Open right navigator panel by pressing ⌥ + ⌘ + 0.

  13. If you want to justify your code or give a proper good looking format to it, simply select the section of the code and press ⌃ + I.

  14. To add documentation to your code, just select the part of the code and press ⌥ + ⌘ + /.

  15. If you want to rename a variable or constant or a method name in its whole scope then select it and press ⌘ + ⌃ + E. Also, if you are using a Macbook with a touch bar, then this option is available in the touch bar too. It's really handy.

  16. If you want to add multiple Auto Layout constraints in IB, you can do that by holding down the key and click.

  17. Hovering your mouse over a view if you hold down the key, you can see its distance from other views.

  18. If you want to quickly open the object library, press ⌘ + ⇧ + L.

  19. If you want to open up the media library, press ⌘ + ⇧ + M.

  20. Press ⌘ + L and type in the line number to quickly move to that line.

I wish you got to learn a few super awesome tricks and shortcuts today. They do make the coding hassle-free. It would be great if you comment on this blog a trick which I didn't mention here.


Happy Coding!!


19 views0 comments

Recent Posts

See All