Nik
Nik

Reputation: 9472

Remove files from Xcode project

I do not know why, but somehow two files were added to project with a mistake as you can see on screenshot. How can I safely remove them from Xcode project? I've already deleted them from disk, but delete button is grayed out in Xcode interface.

delete is grayed out in xcode context menu

Upvotes: 1

Views: 1969

Answers (4)

Dan
Dan

Reputation: 155

Just had this problem today. The fix for me (on Mac) was:

  1. Find YourProjectName.xcodeproj in finder.
  2. Right click > Show package contents.
  3. Inside there, right click on project.xcworkspace > Show package contents.
  4. Open contents.xcworkspacedata (XML format) in any text editor and manually remove the references.

Hope this helps anyone with the same issue!

Upvotes: 2

Will Said
Will Said

Reputation: 404

Quit Xcode and relaunch to fix it.

Upvotes: 1

sudo
sudo

Reputation: 5804

I can't replicate your problem, but you could give this a shot:

Close Xcode. Right-click your .xcodeproj file, show package contents. Make a copy of your project.pbxproj somewhere as a backup, then open the original in TextEdit. Find "MyClass.h" in the file. You should find a few lines containing it; just delete the entire line each time (including the line break). Do the same for "MyClass.m". Then save, and open your project.

Upvotes: 0

Tendulkar
Tendulkar

Reputation: 5540

Do a clean of all targets and then remove the app from simulator. Finally, relaunch it.

Upvotes: 1

Related Questions