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

最新文章

  1. nodejs创建http服务器
  2. 关于CAShapeLayer的一些实用案例和技巧【转】
  3. 关于Android真机调测Profiler
  4. failed jobs because of past close date,关工单报错
  5. R语言绘图高质量输出
  6. eclipse系列: Cannot change version of project facet Dynamic web的解决方法
  7. 升级OSX 10.9 Mavericks后,会导致Finder始终无响应的一个问题
  8. (转)js 中{},[]中括号,大括号使用详解
  9. Markdown常用编辑器
  10. 关于echarts、layer.js和jqGrid的知识点
  11. 源码中的哲学——通过构建者模式创建SparkSession
  12. [LeetCode] Next Greater Element I 下一个较大的元素之一
  13. jinji2
  14. Vuex笔记
  15. 配置Tree Shaking来减少JavaScript的打包体积
  16. ==、===和Object.is()的区别
  17. 25-Python3 错误和异常
  18. WEB应用从服务器主动推送Data到客户端有那些方式?
  19. aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method fai
  20. Django 2.0.1 官方文档翻译: 文档目录 (Page 1)

热门文章

  1. poj 2762 Going from u to v or from v to u? trajan+拓扑
  2. Python四大主流网络编程框架
  3. c++ 查找数组或者容器元素是否存在(find)
  4. Java注册帐号邮箱激活验证实现
  5. java入门书籍很少介绍的java知识
  6. 用docker部署flask+gunicorn+nginx
  7. JavaScript权威指南--脚本化CSS
  8. ASCII 和 Unicode 编码的由来
  9. Android Toast.makeText用法
  10. vsftpd配置手册(实用)