19

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)

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.

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.

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.

paulmelnikow
  • 16,895
  • 8
  • 63
  • 114
Zaky German
  • 14,324
  • 4
  • 25
  • 31
  • 1
    That definitely is a strange message. Note that it is about projects in the workspace. You might be using the workspace feature without knowing it. – ThomasW Jul 28 '11 at 07:16

7 Answers7

15

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.

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.

September 2013 Update: It seems that this bug is happening also on Xcode 5 & 10.8.5.

EladG
  • 794
  • 9
  • 21
  • 1
    I just got this problem (and sovled it by restarting Xcode). My current project is my first iOS app (usually work in PHP and C#). I'm surprised by how many anomalies in Xcode are fixed by closing and reopening it. – Lucas Oct 01 '11 at 12:48
  • 1
    I had exactly the same problem in Xcode 5 under 10.8.5. Shutting down Xcode and reopening it fixed the problem. – Javide Sep 29 '13 at 09:35
  • 1
    Still happens in XCode 6.1.1 under OS X 10.10.1 Grrrr – Logicsaurus Rex Jul 26 '15 at 22:54
11

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.

Community
  • 1
  • 1
DonnaLea
  • 8,643
  • 4
  • 32
  • 32
7

I was able to get past this error by choosing File >> Save As Workspace.

ashevin
  • 124
  • 3
4

For me personally it was a combination of things.

  1. Deleted derived data from Organizer > projects. (Didn't work after this step)
  2. Restarted Xcode. (Worked after this step)
Cliff Viegas
  • 3,216
  • 1
  • 18
  • 10
1

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.

Tom Carpenter
  • 539
  • 4
  • 18
0

Have you ever deleted .xcworkspace in 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 post recommends to delete .xcworkspace for the purpose of enhancing build speed. Well, mind the catch.

Community
  • 1
  • 1
Philip007
  • 3,190
  • 7
  • 46
  • 71
0

I replaced some dead values in project.xcworkspace (Show Package Contents on your Xcode project file) and the problem went away

james_womack
  • 10,028
  • 6
  • 55
  • 74