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. Java使用Log4记录日志

    我们在系统使用中,为了方便查找问题,因此需要记录操作的日志,而目前比较成熟稳定的程序日志记录方式就是Log4,本人也是菜鸟,然后再学习研究中就记录一下使用方式,以方便今后查阅,同时本文章参考了博客园: ...

  3. English trip -- VC(情景课) 8 A Get ready

    Words cashier  # 收银员                a cashier counts money   收钱 custodian  # 清洁工     a custodian  cl ...

  4. hdu-4289 最大流Dinic模板题

    拆点,套模板. 详情见代码. // // main.cpp // hdu_4289 // // Created by Luke on 16/8/29. // Copyright © 2016年 Luk ...

  5. ssh The authenticity of host '10.11.26.2 (10.11.26.2)' can't be established

    The authenticity of host '10.11.26.2 (10.11.26.2)' can't be established. ECDSA key fingerprint is SH ...

  6. 模拟模拟vij1120

    花生采摘 描述 鲁宾逊先生有一只宠物猴,名叫多多.这天,他们两个正沿着乡间小路散步,突然发现路的告示牌上贴着一张小小的纸条:“欢迎免费品尝我种的花生!——熊字”. 鲁宾逊先生和多多都很开心,因为花生正 ...

  7. HDU-4856 Tunnels (BFS+状压DP)

    Problem Description Bob is travelling in Xi’an. He finds many secret tunnels beneath the city. In hi ...

  8. java使用HttpClient

    HttpClient常用的包有两个 org.apache.http.client以及org.apache.commons.httpclient 我常用的是org.apache.http.client. ...

  9. 使用CLOB抛出数字或值错误异常

    今天在调试某个问题的时候,由于使用了很多循环,我需要都打印出来,试图使用clob整体处理之后再打印. 最后抛出此异常:数字或值错误. 网友解释如下: $ oerr ora 650206502, 000 ...

  10. 转载:移动端+微信小程序实现,手机端滑动分页代码思路(ajax)

    //一般在PC上我们要分页都是通过上一页和下一页来实现的,手机通过当下滑到一定程度的时候自动加载下一页面//实现思路:首先加载部分数据,当下滑到某个元素可见的时候,如果还有数据,则新发送请求,然后追加 ...