11
votes

I need to figure out why it is that Xcode, suddenly and with no provocation, starts handing me this error and not allowing me to build my project. When I say, "without provocation", I mean I'm editing text in the database the app delivers text from, and checking my progress in the simulator, doing nothing in Xcode at all except cleaning, building and testing. Everything will be fine for several test sequences, then suddenly, changing nothing in my procedures, the app won't build and I get these errors:

error: remove /Users/casey-cayce/Library/Developer/Xcode/DerivedData/PEM-LTE-2016-gyoajgqmkkoluhgbrhjmgwakiejl/Build/Products/Debug-iphonesimulator/Living the Eucharist.app/images: Directory not empty

error: couldn't remove '/Users/casey-cayce/Library/Developer/Xcode/DerivedData/PEM-LTE-2016-gyoajgqmkkoluhgbrhjmgwakiejl/Build/Products/Debug-iphonesimulator/Living the Eucharist.app/images' after command failed: Directory not empty

I've gone to this Derived Data folder and physically deleted the contents, only to have Xcode restore those contents when I reopen the app, fail the build, then give me the same errors over again. My only solution so far is to completely delete Xcode and the Developer folder, reinstall Xcode, after which it behaves fora little while, but will eventually do the same thing again. I've done this 3 times so far today.

If anyone has any suggestions, please help me get this resolved so I can get this project exported and finished.

Thanks.

Additional info in response to responses:

I have:
1: Closed the project.
2: Opened the Projects, folder and deleted the Derived Data, seen the Projects folder go blank (empty) with "No Projects" showing in the window.
3: Made sure the trash is emptied.
4: Run "WatchDog," an app developed specifically for dealing with Derived Data issues in XCode.
5: Closed Xcode & re-opened.
6: Opened the project, cleaned, and run the Build command.

After all that, the same errors come up again.

6
Why are you cleaning at all?trojanfoe
But isn't the issue happening during the clean?trojanfoe
During the Build or Archive process, after the clean.Cayce
That wasn't clear from your description of the issue.trojanfoe
I'm having this exact same issue. Tried everything. After I blow away DerivedData, it creates it again during the build process, and the same build process fails because it can't delete it. Pretty damned frustrating.Wedge Martin

6 Answers

11
votes

It is ok to delete DerivedData folder, you can delete all files from DerivedData sub-folder (Not DerivedData Folder) directly.

That should not take any effect. Contents of DerivedData folder is generated during the build time and you can delete them if you want. It's not a issue.

All contents of DerivedData will be recreated when you build your projects again.

I suggest you clean project project and build again, ALSO PLEAE MAKE SURE YOUR DELETED DerivedData folder is not in BIN please clean trash, it is important

22
votes

Check your "Copy Bundle Resources" in Build Phase, You should find some files(should be images in your situation) in that list twice. Delete them and rebuild.

1
votes

In Xcode go to Window > Projects, select your project and there will be the delete button to delete the derived data.

1
votes

As of Xcode 9/10 you'll be able to access the Derived Data folder by navigating to

File -> Project Settings

or if you use a Workspace:

File -> Workspace Settings

And press the arrow behind the path:

enter image description here

Go to the folder and delete the derived data

1
votes

Add this to your shell and it will remove the DerivedData

rm -rf ~/Library/Developer/Xcode/DerivedData/*
0
votes

It's not the best option, but helps me a lot of times - create new project and drag all source files from current in to new one.