Is there a way to refactor mixed C++/Objective-C code in Xcode ?? I am writing a game using Cocos2D and Box2D, and the Box2D is written on C++, so every class I write should have .mm extension and therefore when I try to e.g. rename the variable, I got a message like "Xcode can only refactor C and Objective-C code".

答案

Xcode is VERY limited with refactoring, even with plain Obj-C. It's basically renaming and it can't even rename in comments. If it says it can't do something, then it probably can't.

The only way to rename is using find & replace. Note that Xcode can handle regular expressions so it is often good enough.

Of course, the problem is that find & replace doesn't know the programming language and sometimes can add some extra replace or forget to replace something, therefore be extra careful. Clean build is neccessary after every refactoring to check everything got renamed correctly.

You can also use command line tools (e.g. sed) to achieve the same.

answered Apr 5 '13 at 17:19
Sulthan

66.2k14102140
 
    
Thank you! I just wanted to know the way people usually cope with it when working on big projects. Do they use find & replace tool too? – Terko Apr 5 '13 at 18:07
1  
@Terko Hard to say. I guess everybody is a bit different. Also note that XCode is not the only IDE on the market. It's the default and it's free but it's not the only one. I heard very good references for JetBrains, which has "Reliable refactorings" as one of its major features. I don't know whether it can refactor Obj-C++ or not but it's probably much better IDE than XCode. – Sulthan Apr 5 '13 at 19:35
    
@Sulthan - in many respects it is vastly superior , in others not (see Stefen's remark above). I now use xCode strictly for (rare) project setup activities, (always) organizer activities, and (never) code, test and integration. If they can resolve the performance issues and add the missing functions, xCode will soon be ExCode for me. – YvesLeBorg Apr 6 '13 at 12:17 
1  
@Sulthan - mind that Refactoring isn't simply renaming things.. Most of the time I use refactoring features of modern IDEs to extract methods, change signatures or move stuff between classes/namespaces. – Jay Jun 28 '13 at 18:47
1  
1.5 years on AppCode got pretty stable (Still the occasional refactoring bug) so that's what we use now for refactoring.. – cacau Jan 19 '15 at 7:17

Xcode C++ and Objective-C refactoring的更多相关文章

  1. Objective C笔记(第一天)

    • OC语言概述 1.早在20世纪80年代早期,Bard Cox发明了Objective C, 是扩充的C,面向对象的编程语言. 2.NEXTSTEP简称NS a.1985年,Steve Jobs成⽴ ...

  2. Delphi XE5 常见问题解答

    Delphi XE5 常见问题解答 有关于新即时试用的问题吗?请看看 RAD Studio 即时试用常见问答. 常见问题 什么是 Delphi? Embarcadero? Delphi? XE5 是易 ...

  3. Automake

    Automake是用来根据Makefile.am生成Makefile.in的工具 标准Makefile目标 'make all' Build programs, libraries, document ...

  4. 我对XCode Objective

    我对XCode Objective-c Cocoa的简单理解 Xcode Xcode说的通俗一点就是开发OS X 和 iOS 应用程序的. 如果我们想要认真点说 ,Xcode 是运行在操作系统Mac ...

  5. [转] 从 C 到 Objective C 入门1

    转自: http://blog.liuhongwei.cn/iphone/objective-c/ 进军iPhone开发,最大的难点之一就是怪异的Objective C语法了.不过,了解之后才发现,原 ...

  6. 使用命令行工具运行Xcode 7 UI Tests

    原文:Run Xcode 7 UI Tests from the command line 苹果在Xcode 7中引入了一项新技术UI Tests,允许开发者使用Swift或Objective C代码 ...

  7. Objective C ARC 使用及原理

    手把手教你ARC ,里面介绍了ARC的一些特性, 还有将非ARC工程转换成ARC工程的方法 ARC 苹果官方文档 下面用我自己的话介绍一下ARC,并将看文档过程中的疑问和答案写下来.下面有些是翻译,但 ...

  8. 从C#到Objective-C,循序渐进学习苹果开发(5)--利用XCode来进行IOS的程序开发

    本随笔系列主要介绍从一个Windows平台从事C#开发到Mac平台苹果开发的一系列感想和体验历程,本系列文章是在起步阶段逐步积累的,希望带给大家更好,更真实的转换历程体验.前面几篇随笔主要介绍C#和O ...

  9. Xcode如何找到默认的生成路径?

    我最近刚刚入门ObjectiveC,在研习<Objective C程序设计(第6版)>一书. 今天看到有关文件和归档的章节,但是我对XCode的生成文件路径并不了解,然后,在调试代码的时候 ...

随机推荐

  1. python 深拷贝

    from copy import deepcopy #create a tuple tuplex = (, [], True) print(tuplex) #make a copy of a tupl ...

  2. 在浏览器外打开PDF文档

    One function you might find annoying with PDFs and PDF Readers is that when you click on a link to a ...

  3. Web端主流框架,jquery、angular、react、vue

    不得不说,前端技术发展非常迅速,时不多久就有一个新的东西冒出来,并且迅速膨胀发展,让旁观者眼花缭乱,让开发者目眩神迷,但总体上来说,这波互联网大浪潮带动了前端技术的大发展,给曾经那些苦苦挣扎于DOM操 ...

  4. yii CComponent组件 实例说明1

    yii CComponent组件 实例说明 yii中的module,controller都是CComponent的子类,可以说yii的架构基石就是依托在CCompnent基础上的,这里研究下CComp ...

  5. table maker's delimma

    table maker's delimma是计算机浮点数精度的一个问题. 浮点数的表示方式 计算机能表示的数字都是有理数,所有的有理数都可以归结为下面的模式:1.@@@ × 2#### 其中,@@@ ...

  6. SGE:qsub/qstat/qdel/qhost 任务投递和监控

    参考: Oracle Grid Engine qsub命令 SGE - qsub使用范例 SGE作业基本用法 qsub是最为稳定的底层任务投递系统,就是把一个脚本投递到集群的计算节点上运行. 注意,只 ...

  7. 2-24-源码编译搭建LAMP环境-作业 ( By 小甘丶 )

    安装上课的内容要求: 实验环境: VMware Virtual Machine : System Version: CentOS6.8 ( Gan35 ) IP Address : 192.168.3 ...

  8. M爷的线段树

    M爷的线段树 - BUCTOJ 3305 一个长度为n的数列A.修改m次,每次给区间[L,R]中的每一个数加X.查询k次,每次查询第i个元素的值并输出.1<=n<=1e5 ,1<=m ...

  9. CSS样式属性——背景

     背景——包括背景颜色.背景图片,以及背景图片的控制 background-color:设置背景色(transparent表示透明的背景色) background-image:设置元素的背景图片 ba ...

  10. 教你一步一步用 Node.js 制作慕课网视频爬虫

    转自:http://www.jianshu.com/p/d7631fc695af 开始 这个教程十分适合初学 Node.js 的初学者看(因为我也是一只初学的菜鸟~) 在这里,我就默认大家都已经在自己 ...