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打包到pypi小结

       如果你写了一个python库,想让别人快速使用你的库,最简单的方式就是使用python官方出品的库托管网站pypi了.    pypi的全称是Python Package Index,是pyth ...

  2. hdu 5586 Sum 基础dp

    Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Desc ...

  3. jekins 插件离线安装

    官网插件地址:http://updates.jenkins-ci.org/download/plugins/ 系统管理->插件管理->高级 选择一个下载好的插件,然后点击上传即可 然后就会 ...

  4. python 判断字符串是否以数字结尾

    import re def end_num(string): #以一个数字结尾字符串 text = re.compile(r".*[0-9]$") if text.match(st ...

  5. python 集合并集

    #Union setx = set(["green", "blue"]) sety = set(["blue", "yellow& ...

  6. Spring 事物机制总结

    Spring两种事物处理机制,一是声明式事务,二是编程式事务 声明式事物 1)Spring的声明式事务管理在底层是建立在AOP的基础之上的.其本质是对方法前后进行拦截,然后在目标方法开始之前创建或者加 ...

  7. Python day16 tag式整体退出技巧

    在写一些服务器时,往往会多层嵌套循环,可利用tag变量实现整体退出功能,代码: tag=True while tag: print('level1') choice=input('level1> ...

  8. Beta冲刺一《WAP团队》

    β冲刺第一天  1. 今日完成任务情况以及遇到的问题. ①马麒.杜有海:管理员审核表的完善 ②郝明宇:登录.注册界面的完善 ③马宏伟.周欣:前端数据借用与后台的连接 ④乌勒扎:登录与注册功能的测试 2 ...

  9. Flutter学习笔记(三)-- 事件交互和State管理

    先来看看准备界面: image.png 目标是修改图中红色实线框中的喜欢和不喜欢的五角星的修改,以及数字的修改. 在修改之前,有必要先了解一些相关的信息. 知识点 前面简单的提到过,有些Widget是 ...

  10. [.NET开发] C# 读写文件

    1.C#读文件 按行读取文件: public void Read(string path) { StreamReader sr = new StreamReader(path,Encoding.Def ...