重构函数错误-“不是此工作区中 Xcode 3 项目中任何目标的构建阶段的一部分,因此无法重构”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6855283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
refactor function error - "is not part of the build phase of any targets in the Xcode 3 projects in this workspace and so can't be refactored"
提问by Zaky German
Trying to rename a function's name via the refactor->rename button in a categoriy's .h file in XCode 4.1 I'm getting this error: (error and body)
尝试通过 XCode 4.1 中类别的 .h 文件中的 refactor->rename 按钮重命名函数的名称,我收到此错误:(错误和正文)
UINavigationController+ZG.h is not part of the build phase of any targets in the Xcode 3 projects in this workspace and so can't be refactored.
UINavigationController+ZG.h 不是此工作区中 Xcode 3 项目中任何目标的构建阶段的一部分,因此无法重构。
Add the file to the build phase of a target in an Xcode 3 project in this workspace, or make a selection in another file.
将该文件添加到此工作区中 Xcode 3 项目中目标的构建阶段,或在另一个文件中进行选择。
Not sure what it wants and why it's saying something about xcode 3 when i don't have any xcode 3 projects or anything like that.
不确定它想要什么以及为什么当我没有任何 xcode 3 项目或类似的东西时它会说一些关于 xcode 3 的事情。
采纳答案by EladG
I had this issue today on a project which don't use workspace at all. I couldn't get why Xcode behave wired. Auto complete worked, but return some really unrelevant results as my FAMILY NAME (?!) for a class I was working on.
我今天在一个根本不使用工作区的项目中遇到了这个问题。我不明白为什么 Xcode 是连线的。自动完成工作,但返回一些非常不相关的结果作为我的姓氏 (?!) 用于我正在学习的课程。
I found it to be a bug in Xcode 4.1 under OS X 10.7.1 along side with other issues i had. When I reopen my project, the message was gone, refactoring worked as expected and auto-completing worked as well.
我发现它是 OS X 10.7.1 下 Xcode 4.1 中的一个错误以及我遇到的其他问题。当我重新打开我的项目时,消息消失了,重构按预期工作,自动完成也工作正常。
September 2013 Update:It seems that this bug is happening also on Xcode 5 & 10.8.5.
2013 年 9 月更新:此错误似乎也发生在 Xcode 5 和 10.8.5 上。
回答by DonnaLea
Restarting Xcode did not fix this for me (although it does normally fix a lot of things). I also didn't like the idea of File >> Save As Workspace. As the workspace should already be in my .xcodeproj file, so I didn't want another one. I found another solution that fixed it for me: Window >> Organiser and then Delete Derived Data for my project. Found it mentioned in this other question.
重新启动 Xcode 并没有为我解决这个问题(尽管它通常可以解决很多问题)。我也不喜欢文件>>另存为工作区的想法。由于工作区应该已经在我的 .xcodeproj 文件中,所以我不想要另一个。我找到了另一个为我修复它的解决方案:Window >> Organizer,然后为我的项目删除派生数据。发现它在另一个问题中提到。
回答by ashevin
I was able to get past this error by choosing File >> Save As Workspace.
通过选择文件>>另存为工作区,我能够克服这个错误。
回答by Cliff Viegas
For me personally it was a combination of things.
对我个人来说,这是一个组合。
- Deleted derived data from Organizer > projects. (Didn't work after this step)
- Restarted Xcode. (Worked after this step)
- 从管理器 > 项目中删除派生数据。(此步骤后不起作用)
- 重新启动Xcode。(在这一步之后工作)
回答by Tom Carpenter
I have just run into this issue as well. I found that running:
我也刚刚遇到了这个问题。我发现运行:
Product->Clean
产品->清洁
Fixed the problem, and I can now use refractor again.
修复了问题,我现在可以再次使用 refractor。
回答by james_womack
I replaced some dead values in project.xcworkspace (Show Package Contents on your Xcode project file) and the problem went away
我替换了 project.xcworkspace 中的一些无效值(在您的 Xcode 项目文件中显示包内容),问题就消失了
回答by Philip007
Have you ever deleted .xcworkspacein Finder? Although the file will be auto-generated by Xcode again, yet its content will be changed. I think that causes your problem. I saw a postrecommends to delete .xcworkspace for the purpose of enhancing build speed. Well, mind the catch.
你有没有在 Finder 中删除过.xcworkspace?虽然该文件会再次由 Xcode 自动生成,但其内容将被更改。我认为这会导致您的问题。我看到一个帖子建议删除 .xcworkspace 以提高构建速度。好吧,注意问题。

