作为今年的结束,向你推荐一些工具,可以添加到你的iOS开发工具箱,并可以让你2016年的开发变得更容易、更高效。
使用用户断点的力量
我们使用断点的地方有很多,但我发现大多数朋友只使用常规断点进行调试。
实际上,还有很多你能用的地方,例如你可以把普通断点提升为用户断点,并且在你所有的项目中使用,为什么不这么做呢?
因为你可以在执行代码中创建一个特定的符号断点,例如UIApplicationMain:
看到我做了些什么吗?
现在每当调试任何的项目,我已经不这么做了:
我直接这么处理:
没有额外的步骤。
你可以做的更多:
让Xcode更好用
插件:Xcode这里有一些我喜欢的插件,如果你不尝试一下它们,有可能会错过一些很给力的插件功能:
-
Alcatraz—这个插件可以把PackageManager添加到Xcode中,你可以用它安装其它插件。
-
KZLinkedConsole——可以直接从错误日志跳转到源代码。
-
XCodeColors——你不想让你的Xcode控制台有颜色吗?这个插件可以使错误日志更明显。
-
KSImageNamed——增加智能感知和预览你的imageNamed:调用的图片。
-
OMColorSense--增加预览你的用户界面颜色,甚至允许你使用颜色选择器直接修改代码。
-
VVDocumenter--如果你写库你应该添加文档,这个插件可以轻松为您提供上下文感知模板
ps:译者附加
(在安装插件后若发现不能使用,则可以通过这个方法尝试解决:
1.打开xcode插件所在的目录:
~/{用户名}/library/Application Support/Developer/Shared/Xcode/Plug-ins
2.选择已经安装的插件例如VVDocument,右键点击显示包内容,
3.找到info.plist 文件,找到DVTPlugInCompatibilityUUIDs的项目,
4.添加C4A681B0-4A26-480E-93EC-1218098B9AA0(当前你使用的Xcode的号码),这个号码获取方式:
在终端执行 defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID 即可
5.再右键“打开报内容”双击contents\MacOS目录下的一个黑色图标,会打开终端窗口,最后打印“进程已完成”之类,
重启xcode即可。)
隐藏选项
打开你的终端并且这么处理:
-
想看看编译你的工程需要花费多久吗?
1
|
defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES
|
-
更好的自动完成模糊模式?
1
2
|
defaults write com.apple.dt.Xcode IDECodeCompletionFuzzyMode 3
defaults write com.apple.dt.Xcode IDEWorkaroundForRadar6288283 3
|
-
借助多核CPU加快构建时间?
1
|
defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks `sysctl -n hw.ncpu`
|
其它:
-
使用iRamDisk可以让你的派生数据和iOS模拟器有最快的内存。即使新出的固态硬盘都逊色于它。
-
使用KZPlaygrounds可以让你更快地用Swift和Objective-C实现你的新特性。
-
使用界面构建器?你可能为在视图上面添加一个子视图时每次都要移动它而苦恼吗?按住cmd,就不需再那么做了。
===============================English========================================
As we are closing this year, let’s take a look at few simple things you can add to your iOS developer toolbox to make your life easier and be more productive in 2016.
Using the power of User Breakpoints
We use breakpoints quite a lot, but I see that most of my friends only use regular breakpoints whilst debugging.
There is much more you can do with them, e.g. you can elevate your custom breakpoint to User Breakpoint and have them work in all your projects, why would you do that?
Because you can create symbolic breakpoint’s that execute code whenever a specific point is reached, e.g. UIApplicationMain:
Did you see what did I do there?
Now whenever I debug ANY project I’m working on, instead of:
I can get straight to business with:
Without extra steps.
And you can do so much more:
Making Xcode better
Plugins
Here are some of my favourite plugins for Xcode, if you don’t give them a try you might be missing out on some really great features:
-
Alcatraz - this is a plugin that adds a PackageManager into Xcode, which you will use to install all other plugins.
-
KZLinkedConsole - adds ability to jump straight to the source code that logged an error
-
XCodeColors - while would you not want to have colors in your Xcode console? makes error stand out so much more
-
KSImageNamed - adds intelisense with preview to your imageNamed: calls
-
OMColorSense - adds preview to your UIColors and it even allows you to use Color Picker straight from that to modify the code.
-
VVDocumenter - if you write libraries you should be adding documentation to them, this plugin makes it easy by giving you context-aware templates
Hidden options
Open your terminal and type those:
- Want to see how long it takes to build your project?
defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES
- Better autocompletion with Fuzzy mode?
defaults write com.apple.dt.Xcode IDECodeCompletionFuzzyMode 3
defaults write com.apple.dt.Xcode IDEWorkaroundForRadar6288283 3
- Faster build times by leveraging multi-core CPU ?
defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks `sysctl -n hw.ncpu`
Other
- Use iRamDisk to put your Derived Data and iOS Simulator on fastest memory you have. Even on new SSD it makes a difference.
- Use KZPlaygrounds to implement your new features faster in both Swift and Objective-C
- Using interface builder? you probably got annoyed by view being added as a subview everytime you move it? Just hold cmd and it won’t do that ever again.
- See if some other tools I’ve used can save you time