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 day6_dictionary字典的常见方法1_笔记(基本类型结束)

    # 字典的简述 # 1.字典不能做字典的key,列表也不能作为列表的key info={ 'k1':'v1', 'k2':'v2' } print(info) #2.通过键获取值 print(info ...

  2. (转)netty、mina性能对比分析

    转自: http://blog.csdn.net/mindfloating/article/details/8622930 流行 NIO Framework netty 和 mina 性能测评与分析 ...

  3. Java 集合-集合介绍

    2017-10-30 00:01:09 一.Java集合的类关系图 二.集合类的概述 集合类出现的原因:面向对象语言对事物的体现都是以对象的形式,所以为了方便对多个对象的操作,Java就提供了集合类. ...

  4. 【转】ArcGIS API for Silverlight/WPF 2.1学习笔记(二)

      五.Graphics layer 1.新增Graphics layer Graphics layer用于显示用户自定义绘制的点.线.面图形.使用时确保xaml文件中Graphics layer定义 ...

  5. LeetCode--058--最后一个单词的长度

    问题描述 给定一个仅包含大小写字母和空格 ' ' 的字符串,返回其最后一个单词的长度. 如果不存在最后一个单词,请返回 0 . 说明:一个单词是指由字母组成,但不包含任何空格的字符串. 示例: 输入: ...

  6. Android之MVC模式的使用

    MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写,一种软件设计典范,用一种业务逻辑.数据.界面显示分离的方法组织代码 ...

  7. 负载均衡中使用 Redis 实现共享 Session

    最近在研究Web架构方面的知识,包括数据库读写分离,Redis缓存和队列,集群,以及负载均衡(LVS),今天就来先学习下我在负载均衡中遇到的问题,那就是session共享的问题. 一.负载均衡 负载均 ...

  8. 无法安装Java,以下开关中存在错误:“0”

    无法安装Java,以下开关中存在错误:“0”:. 解决方法:以管理员运行

  9. Oracle DISTINCT A 排序问题(转)

    请问Oracle 中有ID,A栏要怎么读出栏的不重复值,并且用ID来排序,請大家帮帮忙? 解决方案: ID | A 1 | x 2 | y 3 | x A栏的不重复值: x, y 但用ID來排序时 x ...

  10. PL/SQL 中 dbms_output.put_line 输出字符长度限制的问题

    可以使用dbms_out.enable()函数来设定允许的长度. PL/SQL 中 dbms_output.put_line 输出字符长度限制的问题