如何设置Xcode插件进行代码自动格式化 [英] How to set Xcode plugin for code auto formatting

查看:104
本文介绍了如何设置Xcode插件进行代码自动格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个插件来自动格式化XCode中的Objective-C代码,拥有一组可选的样式格式也将非常有帮助,

I am searching for a plugin to auto format objective-c code within XCode, it would also be very helpful to have a set of optional styling formats,

我旨在遵循Google的代码约定:

I'm aiming to follow Google's code convention: http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml as a start, any help is appreciated.

推荐答案

2013年4月更新

updated April 2013

如Roger Nolan和rcw3所建议的,您可以使用取消外壳进行更多操作.可以在此处下载最新版本.

As Roger Nolan and rcw3 suggested, you can go a lot further with Uncrustify. The latest release version can be download here.

是否集成到Xcode中取决于安装的Xcode版本.

Integration into Xcode is dependent upon the version of Xcode that is installed.

  • Xcode 4.6&较新

BenoîtBourdon的 BBUncrustifyPlugin-Xcode

Benoît Bourdon's BBUncrustifyPlugin-Xcode

此插件可从Xcode的编辑"菜单(取消选定文件",取消活动文件"和取消选定的行")直接访问取消选定的对象".只需构建项目,即可编译并安装插件.

This plugin provides access to Uncrustify right from Xcode's "Edit" menu ("Uncrustify Selected Files", "Uncrustify Active File", and "Uncrustify Selected Lines"). Just build the project and the plugin is compiled and installed.

自2013年4月2日起,该插件包含Uncrustify 0.60和Uncrustify配置文件.要使用自定义的Uncrustify配置文件,请确保阅读标题为如何自定义Uncrustify配置?"的部分.的 README.md .

As of April 2, 2013, Uncrustify 0.60 and an Uncrustify configuration file are include with the plugin. To use a custom Uncrustify configuration file, make sure to read the section titled "How to customize the Uncrustify configuration?" of README.md.

注意:要在命令行中使用Uncrustify(例如,作为git钩子的一部分),我建议构建并安装

Note: To use Uncrustify from the command line, for example as part of a git hook, I recommend building and installing Uncrustify independently. For consistency sake, I also recommend replacing the version of Uncrustify that comes with the plugin with a link to the version Uncrustify that was independently built and installed. The following is how to do that:

cd ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/UncrustifyPlugin.xcplugin/Contents/Resources
mv uncrustify uncrustify.orig
ln -s /usr/local/bin/uncrustify uncrustify

  • Xcode 4.x
    • Xcode 4.x
    • Jonah Williams的 Xcode 4中的代码格式

      Jonah Williams' Code Formatting in Xcode 4

      • Xcode 3.x

      Jonah Williams的 Xcode中的代码格式

      Jonah Williams' Code Formatting in Xcode

      我用于Objective-C的Uncrustify 0.60配置文件位于此处.

      The Uncrustify 0.60 configuration file that I use for Objective-C is located here.

      要为新版本的Uncrustify更新Uncrustify配置文件,请启动终端并输入:

      To update the Uncrustify configuration file for a new version of Uncrustify, start a Terminal and type:

      mv uncrustify.cfg uncrustify.cfg.old
      uncrustify -c uncrustify.cfg.old --update-config > uncrustify.cfg
      

      要查看对Uncrustify配置所做的更改,请在终端类型中:

      To see the changes made to the Uncrustify configuration, in the terminal type:

      diff uncrustify.cfg.old uncrustify.cfg
      


      要查看Uncrustify配置文件的文档版本

      要查看Uncrustify配置文件的文档版本,请启动终端并输入:


      To View a Documented Version of the Uncrustify Configuration File

      To view a documented version of the Uncrustify configuration file, start a Terminal and type:

      uncrustify -c uncrustify.cfg --show-config
      

      这篇关于如何设置Xcode插件进行代码自动格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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