Xcode有任何等效的ReSharper吗? [英] Any ReSharper equivalent for Xcode?

查看:75
本文介绍了Xcode有任何等效的ReSharper吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名完整的Xcode/Objective-C/Cocoa新手,但是我学习很快,并且真正开始喜欢使用新的语言,平台和范例.

I'm a complete Xcode/Objective-C/Cocoa newbie but I'm learning fast and really starting to enjoy getting to grips with a new language, platform and paradigm.

不过有一件事,就是将Visual Studio与R#一起使用了很长时间,我对编码工具(例如重构和完成等)一无所知,而据我所知,Xcode的内置功能相当有限.对这些东西的支持.

One thing is though, having been using Visual Studio with R# for so long I've kind of been spoiled with the coding tools such as refactorings and completion etc and as far as I can tell Xcode has some fairly limited built in support for this stuff.

请注意,有人知道Xcode环境中是否有任何插件或任何可用于添加编码助手的插件,例如根据类接口定义自动生成实现框架等吗?

On that note, does anyone know if any add-ins or whatever are available for the Xcode environment which add coding helpers such as automatically generating implementation skeletons from a class interface definition etc?

我怀疑没有,但我想这无济于事.

I suspect there aren't but I suppose it can't help to ask.

推荐答案

听起来好像您在寻找三大要素:代码模板,重构工具和自动完成.

You sound as if you're looking for three major things: code templates, refactoring tools, and auto-completion.

好消息是Xcode 3及更高版本具有出色的自动完成功能和模板支持.默认情况下,您必须通过按Escape键显式请求完成. (这实际上在所有NSTextView中都有效;请尝试!!)如果您希望自动显示补全,可以转到首选项-> Code Sense 并进行设置弹出窗口将在几秒钟后自动出现.您应该找到C和Objective-C代码的良好完成,以及C ++的良好完成.

The good news is that Xcode 3 and later come with superb auto-completion and template support. By default, you have to explicitly request completion by hitting the escape key. (This actually works in all NSTextViews; try it!) If you want to have the completions appear automatically, you can go to Preferences -> Code Sense and set the pop-up to appear automatically after a few seconds. You should find good completions for C and Objective-C code, and pretty good completions for C++.

Xcode还具有可使用的可靠模板/骨架系统.通过转到编辑->插入文本宏,可以查看默认情况下可用的模板.当然,您不希望用鼠标插入文本宏.这是错误的.相反,您有两个选择:

Xcode also has a solid template/skeleton system that you can use. You can see what templates are available by default by going to Edit -> Insert Text Macro. Of course, you don't want to insert text macros with the mouse; that defeats the point. Instead, you have two options:

  1. 返回首选项,转到键绑定,然后在菜单键绑定下,为您经常使用的宏分配特定的快捷方式.我个人不愿意这样做,但是我知道很多伟大的Mac开发人员都可以这样做
  2. 使用CompletionPrefix.默认情况下,几乎所有模板都有一个特殊的前缀,如果您键入然后按转义键,将导致插入模板.您可以使用Control-/在完成字段之间移动.

  1. Back in Preferences,go to Key Bindings, and then, under Menu Key Bindings, assign a specific shortcut to macros you use often. I personally don't bother doing this, but I know plenty of great Mac devs who do
  2. Use the CompletionPrefix. By default, nearly all of the templates have a special prefix that, if you type and then hit the escape key, will result in the template being inserted. You can use Control-/ to move between the completion fields.

您可以看到 Xcode的默认宏及其相关的CompletionPrefix es的完整列表弯曲的旋转.

You can see a full list of Xcode's default macros and their associated CompletionPrefixes at Crooked Spin.

您还可以添加自己的宏,或修改默认值.为此,请编辑文件/Developer/Library/Xcode/Specifications/{C,HTML}.xctxtmacro.语法应该是不言自明的,即使不是很友好.

You can also add your own macros, or modify the defaults. To do so, edit the file /Developer/Library/Xcode/Specifications/{C,HTML}.xctxtmacro. The syntax should be self-explanatory, if not terribly friendly.

不幸的是,如果您沉迷于R#,那么重构选项会让您感到失望.通过上下文菜单或单击Shift-Apple-J,可在Xcode中提供基本的重构.从那里,您可以提取和重命名方法,通过类层次结构以及其他一些常见操作来对其进行升级和降级.不幸的是,Xcode或任何第三方实用程序都没有提供任何接近Resharper的功能,因此在这方面,您目前不走运.值得庆幸的是,Apple已经在作品中展示了Xcode的版本,这些版本的重构功能得到了极大的改善,因此希望您不必等太久就可以开始改善这种情况.

Unfortunately, if you're addicted to R#, you will be disappointed by your refactoring options. Basic refactoring is provided within Xcode through the context menu or by hitting Shift-Apple-J. From there, you can extract and rename methods, promote and demote them through the class hierarchy, and a few other common operations. Unfortunately, neither Xcode nor any third-party utilities offer anything approaching Resharper, so on that front, you're currently out of luck. Thankfully, Apple has already demonstrated versions of Xcode in the works that have vastly improved refactoring capabilities, so hopefully you won't have to wait too long before the situation starts to improve.

这篇关于Xcode有任何等效的ReSharper吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆