Ios--xcode Tips for use

Source: Internet
Author: User
Tags sublime text

This article was translated from David McGraw's blog by Cocoachina translation Group members (blogs)
Original: Xcode Tips that would help you conquer Xcode
When it comes to iOS development tools, one of the things that's definitely familiar to all iOS developers is Xcode. Xcode is the driving force that makes all the amazing iOS apps possible.

Xcode can help us do a lot of things, but it's also a bit of a headache. For beginners, you may feel that Xcode is too heavy. And for those who have had years of experience, they are constantly learning some details to improve their productivity. My advice to beginners is not to be able to learn all about Xcode without thinking about it. Focus on the most important part of the moment, and then slowly expand to new knowledge based on experience.

In this article, I'll mention some of the things that can help you improve your productivity. Some of this content may have been forgotten, but some should be able to solve the problems you often encounter.

    • You'll learn how to customize Xcode to increase productivity

    • You'll learn some features to help you manage your code

    • You will learn some hints to help you master the engineering development

Xcode Behaviors

Behaviors is a magical thing that allows Xcode to automate a number of subsequent operations based on your actions. Imagine that you are running a program that has encountered a breakpoint or error. By default, Xcode automatically opens the debug window, jumps to the wrong code at the current tab, and completely disrupts the editor. Now let's set it up to prevent this from happening.

Open Xcode preferences and you'll see a tab called behaviors. Here we can define the behavior of Xcode when different kinds of states change, such as what Xcode does when the build starts, and what Xcode does when the build succeeds or fails. You can have Xcode play a sound, open a new tab, show navigation, and so on.

For this example, we want to change some of the behavior of Xcode when the app runs. When the app pauses because of a breakpoint or error, we want to do the following things:

    • Play Sound (Hero sounds good for me, but you can switch to other, including custom sounds)

    • Show Debug tab page

    • Show Debug Navigation

    • Debug zones display both variables and consoles

I chose to open a new tab here because I didn't want Xcode to change my current working status. So I can easily go back to where I wrote the code before. In addition, I did not close some panes opened by Xcode for debugging, the whole experience is focused on a separate tab.
You can take some time to explore other Xcode behaviors and find the most appropriate one based on your own development style. You might think some of Xcode's default behavior is annoying, and maybe you can turn it off in behaviors.

Managing Devices and emulators

Have you ever thought that you could actually manage the list of devices in the device drop-down box in Xcode?

Then think about reading the database in the device to verify that the data in the table is set correctly. Have you ever met a simulator in the drop-down box for Xcode? Now open Window > Devices.

Here you can see the connected devices and the available emulators. If you need to add or remove emulators, click the + button (remove click-button) in the lower left corner. If the simulator can't be found, you can get here to recover them.

Finally, another useful feature here is the ability to download the app's container.

In the past you might have accessed the emulator folder to get the data, but what about the real machine? Now that it's easy to get saved photos, database files, and so on, you can download a container containing documents, Libarary, and temp folders so you can get the data on your device.

Update the app's display name

One of the many developers often encounter is that the name of the project being created is not what you want it to be. I often see some people rename and refactor (refactor) the entire project to show the correct name. If you know that adding a key to your project's info.plist will change the app display name, you'll be happy. This key is the bundle display name.

Improve readability & Xcode extensions

There are a lot of plugins that can improve xcode productivity now. Some developers have even created some very good themes to replace the Xcode default theme. To be honest, the default theme looks pretty uncomfortable. So how can we easily get to these plugins? Go to Alcatraz.io now and download a very useful Xcode package Manager.

Here are some of the plugins I've recently used:

    • Scxcodeminimap: This plugin looks like the one in sublime text. It can display a thumbnail of an editor and easily view and scroll through the code.

    • Revealplugin: If you use reveal, this plugin can start reveal quickly.

    • The template file for the Realmplugin:realm model object. Realm is a database for mobile devices. )

    • Vvdocumenter-xcode: help you quickly generate a comment for a method.

    • Adjustfontsize: When you show the code, you may need to quickly zoom in on the font, which allows you to adjust the font size by command+ plus a minus sign.

    • Lin: Displays code completion for nslocalizedstring.

There is a localization plugin rephrase being developed that deserves attention. When it is released, it is possible to become another tool to save time.

The theme I'm using today is dusk, and I'm sure that's the default theme. There are also many color themes that you can download via Alcatraz.

Download documents and Legacy emulators

When you install a new version of Xcode, you may find that you do not have an emulator for the previous iOS system. This is a problem when testing the app. You can install the Legacy emulator in the Download tab in preferences.

You can download the Legacy emulator here and manage them in Windows > devices. You can also download a document that is not preloaded by Xcode.

Organization Source files

With a drop-down box above the source file, you can see all the properties and methods.

When you click on this location, the drop-down box will show you the details of this file. In the source code you can also use such as//FIXME: OR//TODO: OR//mark: To add tags.

Quickly open files

Sometimes you may need to open a new file, but also keep the current file. There are several options.

You can open the Assistant editor and then display the file there. Click View > Assistant editor > Show Assistant Editor.

You can double-click the file you want to open. This will open a new window.

You can click through option+shift+, which will pop up a box that lets you choose where to open the file.

Jump to document

A quick jump to a document can save you a lot of time. You may be writing uitableviewdelegate, but you don't remember all the relevant methods. You can quickly jump to a document by command+ click on the symbol.

Generate document

Download and install the plugin Vvdocumenter-xcode, you don't have to write the comment code manually. Just enter three slashes///to quickly generate annotations.

Another benefit is that these annotations can also be displayed in the Xcode document preview. You can preview the document by option+ clicking on it on a single method.

Creating Code Snippets

If you often need to enter exactly the same format code, that code snippet is useful. For example, I have a code snippet that can automatically populate a new TableView or CollectionView class, and there are delegate methods I need. I also have some small snippets to help me quickly generate code for Typealias, Singleton, GCD, and so on.

To generate a code snippet, open the Snippent panel in file inspector.

In the editor, enter the fragment you want to create. Note that if a placeholder is required, enter < #placeholder-name#>. Select the code, press and hold for one second, and then drag into the snippet area.

You can then edit the clips to add more details. The most important point is "complete shortcut keys". Enter the keyword in the editor to select the clip. Or you can drag code snippets from the area into the editor.

In a couple of days I'll collect all my clips and share them.

Improved commissioning with Chisel

Facebook has developed a set of LLDB commands to make debugging easier. If you haven't chisel yet, go to GitHub to install it now. To make you understand what Chisel is for, here are some of my favorite commands. These commands save me a lot of time and mind to memorize those grammars.

    • Pviews: Recursively prints the view on the key window.

    • Visualize: Open UIImage, Cgimageref, UIView, and Calayer in the preview app on your Mac.

    • Show/hide: Shows or hides the specified view or layer.

    • Border/unborder: Shows or hides the View/layer border to find out where it is.

Chisel also has many commands, enter help in Lldb to see the built-in and user-defined commands.

Version Editor

If you need to look at what's changed in the file, you can take advantage of Xcode's built-in version editor instead of the complex git.

You can quickly open the version editor by tapping the double-arrow button in the upper right corner, or by using View > Version Editor > Show version Editor. Imagine that there are a lot of test code that doesn't need to be submitted, it will be displayed in the version editor, and will let you quickly discard those changes. You can use the source control interface to do this, but using the version editor is the simplest.

6 keys to remember and set

Some shortcut keys are not set by default, I suggest you open preferences > key Bindings and modify them as needed.

    • Command +/: Comment/Uncomment code

    • Command + [or]: Indent code forward or backward

    • Command + left and RIGHT ARROW keys: Move cursor to beginning or end of line

    • Control + S: Select the word: Default is not set. Key Bindings corresponding key is Select Word)

    • Option + Command + E: (based on the current range of selected words): The default is not set, and do not know what the effect is. )

    • Option + LEFT ARROW key: Move cursor by word

    • ESC: Show/Hide Auto Fill popup.

There are many more shortcuts to find the right style for you, ingenious.

Points

In this article we mention some of the tools--xcode you use most often. Most of what I have shown is to improve my productivity. I'm not trying to be simple (you won't see me using a keyboard), but I'm freeing myself from recurring problems. When you have more experience, you can find the way that suits you best. That's the point. See how you can apply what you've learned in this article.

Ios--xcode Tips for use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.