任何与 Xcode 等效的 ReSharper?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20420/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Any ReSharper equivalent for Xcode?
提问by Shaun Austin
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.
我是一个完整的 Xcode/Objective-C/Cocoa 新手,但我正在快速学习并且真正开始享受掌握新语言、平台和范式的乐趣。
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.
但有一件事是,长期以来我一直在使用带有 R# 的 Visual Studio,我已经被编码工具(例如重构和完成等)宠坏了,据我所知 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?
关于这一点,有没有人知道是否有任何插件或任何可用于 Xcode 环境的插件,它们添加了编码帮助程序,例如从类接口定义自动生成实现骨架等?
I suspect there aren't but I suppose it can't help to ask.
我怀疑没有,但我想这不禁要问。
采纳答案by Benjamin Pollack
You sound as if you're looking for three major things: code templates, refactoring tools, and auto-completion.
你听起来好像在寻找三个主要的东西:代码模板、重构工具和自动完成。
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 Senseand 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 3 及更高版本具有出色的自动完成和模板支持。默认情况下,您必须通过按转义键明确请求完成。(这实际上适用于所有NSTextViews;试试吧!)如果你想让补全自动出现,你可以去Preferences-> Code Sense并将弹出窗口设置为在几秒钟后自动出现。您应该会找到 C 和 Objective-C 代码的良好补全,以及 C++ 的相当好的补全。
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:
Xcode 还有一个可靠的模板/骨架系统,您可以使用它。您可以通过转到“编辑”->“插入文本宏”来查看默认情况下可用的模板。当然,您不想用鼠标插入文本宏;这不合时宜。相反,您有两个选择:
- 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
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.You can see a full list of Xcode's default macros and their associated
CompletionPrefixesat Crooked Spin.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.
- 返回Preferences,转到Key Bindings,然后在Menu Key Bindings 下,为您经常使用的宏指定一个特定的快捷方式。我个人不介意这样做,但我知道很多伟大的 Mac 开发者都这样做
使用
CompletionPrefix. 默认情况下,几乎所有模板都有一个特殊的前缀,如果您键入然后按转义键,将导致插入模板。您可以使用 Control-/ 在完成字段之间移动。您可以在Crooked Spin 中查看Xcode 默认宏及其关联
CompletionPrefixes的完整列表。您还可以添加自己的宏,或修改默认值。为此,请编辑文件
/Developer/Library/Xcode/Specifications/{C,HTML}.xctxtmacro. 语法应该是不言自明的,如果不是非常友好的话。
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.
不幸的是,如果您沉迷于 R#,您会对重构选项感到失望。通过上下文菜单或按 Shift-Apple-J 在 Xcode 中提供基本重构。从那里,您可以提取和重命名方法,通过类层次结构提升和降级它们,以及一些其他常见操作。不幸的是,Xcode 和任何第三方实用程序都没有提供任何接近 Resharper 的功能,因此在这方面,您目前运气不佳。值得庆幸的是,Apple 已经在工作中展示了 Xcode 版本,它们极大地改进了重构功能,所以希望您不必等待太久,情况就会开始改善。
回答by John Gallagher
I'm excited to say that JetBrains have decided to make a decent IDE for Objective-C coders.
我很高兴地说 JetBrains 决定为 Objective-C 编码人员制作一个不错的 IDE。
It's called AppCodeand it's based on their other tools like RubyMine and Resharper. It's not native Cocoa, but has loads of raw refactoring power.
它被称为AppCode,它基于他们的其他工具,如 RubyMine 和 Resharper。它不是原生 Cocoa,但具有大量原始重构能力。
http://www.jetbrains.com/objc/index.html
http://www.jetbrains.com/objc/index.html
I've started using it for my main Objective C project and I'm already in love. It's still in it's infancy, but for code editing and refactoring it already blows Xcode away.
我已经开始在我的主要 Objective C 项目中使用它,而且我已经爱上它了。它仍处于起步阶段,但对于代码编辑和重构,它已经让 Xcode 大吃一惊。
Update
更新
It's now at a totally usable speed. I've switched over to it full time and it still blows my mind how amazing refactoring and coding is compared with Xcode. It just handles so much for you - auto importing, almost infinite customisation. It makes Xcode look like a toy.
它现在处于完全可用的速度。我已经全职切换到它,它仍然让我震惊,与 Xcode 相比,重构和编码是多么惊人。它只是为你处理这么多 - 自动导入,几乎无限的定制。它让 Xcode 看起来像一个玩具。
回答by Chris Hanson
Xcode has refactoring for C and Objective-C built in. Just select what you'd like to refactor, choose "Refactor..." from either the menu bar or the contextual menu, and you'll get a window including the available refactorings and a preview area.
Xcode 内置了针对 C 和 Objective-C 的重构。只需选择您想要重构的内容,从菜单栏或上下文菜单中选择“重构...”,您将获得一个包含可用重构的窗口和预览区。
Xcode doesn't currently have a public plug-in API; if there are specific types of plug-ins you'd like Apple to enable, file enhancement requests in the Bug Reporter. That way Apple can count and track such requests.
Xcode 目前没有公开的插件 API;如果您希望 Apple 启用特定类型的插件,请在Bug Reporter 中提交增强请求。这样 Apple 就可以计算和跟踪此类请求。
However, there are third-party tools like Accessorizerand mogenerator(the latest release is mogenerator 1.10) that you can use to make various development tasks faster. Accessorizer helps you create accessor methods for your classes, while mogeneratordoes more advanced code generation for Core Data managed object classes that are modeled using Xcode's modeling tools.
但是,您可以使用诸如Accessorizer和mogenerator(最新版本是mogenerator 1.10)之类的第三方工具来更快地执行各种开发任务。Accessorizer 可帮助您为类创建访问器方法,同时mogenerator为使用 Xcode 建模工具建模的 Core Data 托管对象类生成更高级的代码。
回答by Chris Hanson
Just so people know, Accessorizerdoes more than just generate accessors (both 1.0 and properties for 2.0) it also generates Core Data code for persisting non-standard attributes, your NSSet accessors for custom to-many relationships.
众所周知,Accessorizer不仅仅生成访问器(1.0 和 2.0 的属性),它还生成用于持久化非标准属性的核心数据代码,以及用于自定义对多关系的 NSSet 访问器。
In fact, Accessorizerwill help provide you with the init, keypath, keyed-archiving, indexed accessors, accessors for unordered collections such as NSSet, copyWithZone, KVO, key-validation, singleton overrides, dealloc, setNilForKey, non-standard attribute persistence (Core Data), locking, headerdoc, convert method to selector, NSUndoManager methods and more.
事实上,Accessorizer将帮助您提供初始化、keypath、keyed-archiving、indexed accessors、无序集合的 accessors,例如 NSSet、copyWithZone、KVO、key-validation、singleton overrides、dealloc、setNilForKey、非标准属性持久化( Core Data)、锁定、headerdoc、将方法转换为选择器、NSUndoManager 方法等等。
回答by Igor Pchelko
I found some xtmacro files in Xcode.app package: /Developer/Applications/Xcode.app/Contents/PlugIns/TextMacros.xctxtmacro/Contents/Resources
我在 Xcode.app 包中发现了一些 xtmacro 文件: /Developer/Applications/Xcode.app/Contents/PlugIns/TextMacros.xctxtmacro/Contents/Resources
Installed Xcode ver. 3.2.5.
安装了 Xcode 版本。3.2.5.

