When it comes to iOS development tools, one of the things that must be 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, it may feel xcode too heavy. And for those who have had a few years of experience, they are still learning some details to improve productivity. My advice to novices is to stop thinking about it and learn all the knowledge about Xcode. Focus on the most important part of the moment and then slowly expand into new knowledge based on experience.
In this article, I'll mention a few things that will help you improve your productivity. Some of this may have been forgotten, but some should be able to solve the problems you often encounter.
You will learn how to customize Xcode to increase productivity
You'll learn some features to help you manage your code.
You will learn a few tips to help you develop the overall control project
Xcode Behaviors
Behaviors is a magical thing that allows Xcode to automate some subsequent operations according to 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 page, and completely disrupts the editor. Now we are setting up to prevent this from happening.
Turn on Xcode preferences to see a tab called behaviors. Here we can define the behavior of Xcode when different kinds of state change, such as what Xcode to do when the build starts, and what Xcode to do when the build succeeds or fails. You can let Xcode play sound, open a new tab, display navigation, and so on.
For this example, we want to change some of the behavior of the Xcode in the app runtime. When the app is paused because of a breakpoint or error, we want to do the following:
Play sound (Hero sounds are good for me, but you can switch to other ones, including custom sounds)
Show Debug tab page
Show Debug Navigation
Debug zones display variables and consoles at the same time
Here I choose to open a new tab because I don't want Xcode to change my current working status. So I can easily go back to where I wrote the code before. Besides, I didn't close the Xcode. Some panes open for debugging, the whole experience is centered on a separate tab page.
You can take the time to explore Xcode other behaviors and find the best fit according to your own development style. You may think that some of the default behavior of Xcode is annoying, and maybe you can turn it off in behaviors.
Managing Devices and Simulators
Have you ever thought that you could actually manage the list of devices in the Xcode in the Device Drop-down box?
Then think about reading the database in the device to verify that the data in the table is set correctly. Have you ever encountered a Xcode in the dropdown box? Open Window > Devices now.
Here you can see the connected devices and the available simulators. If you need to add or remove an emulator, click the + button (remove click-button) in the lower left corner. If the simulator is not found, you can come here to restore 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? It's easy to get saved photos, database files, and so on, and you can download a container that contains documents, libarary, and temp folders. This will get the data on the device.
Update the display name of the app
One of the most common problems developers encounter is that the created project does not display the name they want. I often see people renaming and refactoring (refactor) the entire project to display the correct name. If you know that adding a key to the project's Info.plist can change the app display name, you'll be happy. This key is bundle display name.
Improved Readability & Xcode expansion
Now there are a lot of plug-ins can improve the productivity of Xcode. Some developers have even created some very good topics to replace the Xcode default theme. To tell you the truth, the default theme still looks pretty uncomfortable. So how can we easily get these plug-ins? Now go to Alcatraz.io and download a very good Xcode package manager.
Here are some of the plugins I used recently:
Scxcodeminimap: This plugin and the one in sublime text look like. It can display an editor thumbnail and easily view and scroll through the code.
Revealplugin: If you use reveal, this plugin can quickly start reveal.
The template file for the Realmplugin:realm model object. Realm is a mobile device-oriented database. )
Vvdocumenter-xcode: Helps you quickly generate a comment for a method.
Adjustfontsize: When you show the code, you may need to quickly enlarge the font, which allows you to resize the font by command+ plus a minus sign.
Lin: Show code completion for nslocalizedstring.
There is a localized plug-in rephrase being developed that deserves attention. When it is released, it is possible to become another time-saving tool.
My current theme is dusk, and I believe this is the default theme. There are many color themes that you can download by Alcatraz.
Downloading 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 an older version of the emulator in the Download tab of your preferences.
You can download the old version of the simulator here and manage them in Window > devices. You can also download Xcode documents that are not preloaded.
Organize source files
You can view all the properties and methods by using a Drop-down box above the source file.
When you click on this position, the dropdown box displays the details of the file. In the source code you can also use for example//FIXME: OR//TODO: OR//mark: To add tags.
Quickly open a file
Sometimes you may need to open a new file, but keep the current file as well. 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 the option+shift+, which will pop up a box that lets you choose where to open the file.
Jump to document
The ability to quickly jump to a document can save a lot of time. You may be writing uitableviewdelegate, but you don't remember all the relevant methods. You can quickly jump to the document by clicking on the symbol command+.
Generate document
Download and install the plugin vvdocumenter-xcode, you do not have to manually write the annotation code. You can quickly generate annotations by simply entering three slash///.
Another benefit is that these annotations can be displayed in the Xcode document preview. option+ click on a method to preview the document.
To create a code fragment
If you often need to enter code in exactly the same format, the code snippet is useful. For example, I have a snippet of code that automatically populates a new TableView or CollectionView class and also has the delegate method I need. I also have some small clips to help me quickly generate code for Typealias, Singleton, GCD, and so on.
To generate a snippet, open the Snippent panel in file inspector.
In the editor, enter the fragment you want to create. Note that if you need a placeholder, enter < #placeholder-name#>. Select the code, hold down one second, and then drag into the code fragment area.
You can then edit the clips to add more detail. The most important thing is to "finish the shortcut". Enter the keyword in the editor to select the fragment. Or you can drag code snippets from the area to the editor.
I'll collect all my clips and share them in two days.
improving debugging with Chisel
Facebook has developed a set of LLDB commands to make debugging easier. If you haven't chisel, go to GitHub installation now. In order for you to understand what Chisel is, I have listed some of my favorite commands. These commands save me a lot of time and brains to remember those grammar.
Pviews: Recursively prints view on key window.
Visualize: Open UIImage, Cgimageref, UIView, and Calayer in the preview application on the Mac.
Show/hide: Shows or hides the specified view or layer.
Border/unborder: Shows or hides the View/layer border to find where it is.
Chisel also has many commands to enter help in lldb to view built-in and user-defined commands.
Version Editor
If you need to look at what's changed in the file, you can use the Xcode version editor instead of the complex git.
You can open the version editor quickly by clicking the double arrow button in the upper-right corner, or through View > Version Editor > Show version Editor. Imagine that there are a lot of test code that you don't need to submit, which is displayed in the version editor and allows you to quickly discard the changes. You can use the source control interface to do this, but using the version editor is the easiest.
6 Shortcuts worth remembering and setting
Some shortcuts are not set by default, and I recommend that you open preferences > key bindings and modify them as needed.
Command +/: Comment/Uncomment code
Command + [or]: Indent code forward or backward
Command + Left-right arrow: Move the cursor to the beginning or end of the line
Control + S: Select the word: Default is not set. Key bindings corresponding key is Select Word)
Option + Command + E: (Across the selected words according to the current range) (the default is not set, do not know what the effect is.) )
Option + LEFT ARROW key: Move cursor by word
ESC: Show/Hide auto fill pop-up box.
There are lots and lots of 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 pure fast (you won't see me using just one keyboard), but I'm liberating myself from recurring problems. When you have more experience, you can find the best way for you. That's the point. See how you can apply what you've learned in this article.