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.
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.
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
In Xcode go to Window > Projects, select your project and there will be the delete button to delete the derived data.
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:
Go to the folder and delete the derived data
Add this to your shell and it will remove the DerivedData
rm -rf ~/Library/Developer/Xcode/DerivedData/*
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.
Related
Any change I do in Xcode, build successfully but when I review it in simulator or transfer it to my iPhone, the previous successful build which was sent to the store is running.
It was a working application with history of changes in app store, then I decided to change the name and unique identifier. All went well and I was able to deploy first changes to the store, after that xcode started to show this odd behavior. I made changes, built successfully but the previous version showed up in simulator etc.
Then I found a silly workaround, every change I made, I rebuilt the environment by pull the code from my repo and
#cordova add platform ios#4.5.4
#pod update
#pod setup
#pod install
Then open the Xcode and built the project, then everything was as expected.
but unfortunately this trick stopped working as well and I stuck.
I do clean
I do clear DerivedData folder
I do use "watchdog" application to do cleaning
Did I miss anything?
How to clear Xcode cache manually
1. Clean the build
Tip: If you’re trying to fix a problem with Xcode crashing, it’s worth cleaning the project build first. This will get rid of the current build and create a new one next time you run the code.
With the project open in code, go to the menu bar, choose Product, and select Clean or:
With the project open, press Command + Shift + K.
2. Clean out the build folder
To clean out the build folder, and get rid of cache files, do the following:
In the Code project, click on the Product menu while holding down the Option (Alt) key and choose Clean build folder, or:
Press Command + Shift + Option + K.
3. Reset Simulator content and settings
If neither of the steps above resolves your problem, try resetting the simulator content and settings:
Go to the menu and choose iOS Simulator, then click Reset Content and Settings.
4. Delete derived data
If you’re still having problems, try deleting derived data, which will force Xcode to recreate it when you next run it.
In the menu, choose Window, then Organizer.
Now select Projects, and then click Select your project.
Choose the project whose derived data you want to delete.
In the window that opens, you’ll see see the Derived Data folder listed, along with its Finder path.
To the right of the folder, there’s a Delete button. Press it.
Now, delete the module cache.
Go to: ~/Library/Developer/Xcode/DerivedData/ModuleCache.
Drag the files from the ModuleCache folder to the Trash and empty it.
Source: https://macpaw.com/how-to/clear-xcode-cache
For my case, it turned out to rebuild the whole environment to get it fixed.
One basic point that needs to be highlighted is using "cordova prepare" after any changes.
DerivedData keeps returning into my project no matter how many different ways I try to delete it. This is causing a compile error.
I believe it is related to my deletion of my Core Data model class and extension (I realized I needed to add an additional property and this seemed easier than migrating since I hadn't actually implemented it yet). I deleted the files and removed the reference to these files, but that seems to have not worked. This is the error I've received:
I have tried:
-Cleaning
-Cleaning Build Folder
-Resetting Simulator Content and Settings
-Removing the DerivedData folder using "git rm -rf --cached ."
-Deleting DerivedData folder using Finder, Xcode and Terminal
-Deleting the Module Cache
-Deleting Xcode preferences (defaults delete com.apple.dt.Xcode)
-All of the above combined with quitting Xcode and/or restarting my computer
-Following all suggestions in the following threads on SO:
Xcode 6 Swift code completion not working
How can I delete derived data in Xcode 8?
Xcode keeps remaking derived data folder after I delete it
https://forums.developer.apple.com/thread/81265
https://iosdevcenters.blogspot.com/2015/12/how-to-delete-derived-data-and-clean.html
For the sheer hilariousness of it all, I have my project folder open in Finder when I try to run the project and can see the DerivedData folder being created as soon as I press the play button. Good times.
This is a view of my build/compile settings in Xcode to show that I don't have those files listed twice:
How can I fix this?
The error suggests that you have Core Data code generation turned on and also have a copy of the generated code (or at least a file with the same name) in your source code repository. That's why it complains of a duplicate. One is located in your Model folder, and the generated copy is located in derived data.
You can resolve this by either
Changing the setting in your data model so that Core Data doesn't generate code for this entity anymore, or
Deleting your copy and letting Core Data do its thing.
Either is valid and should work. Or, if the files are actually different in some meaningful way, rename yours so that the name doesn't conflict.
On a related note, the derived data folder always comes back because that's where Xcode puts all of the stuff it generates while compiling your project. It's not just generated source code, it's also things like compiled object code files and eventually the app itself. It comes back because that's how Xcode compiles the project.
You can't prevent Xcode from generating derived data for your project. No matter how many times you delete the folder, it will always regenerate.
I've come across similar issues in the past where the compile time error points to derived data, but something else is causing the issue.
From the looks of it, some of your files are being included twice in your project, and your getting name collisions. Check that you don't have duplicates in you build settings for bundled/compiled resources.
The problem started when I got into the project and saw I have no scheme. Couldn't create new scheme except for the cocoa-pods target. Then I went into my project via finder, and noticed that the project was backedup into the iCloud, and when downloaded it it appeared in the schemes and ran fine.
So I am with this project for a while now, started it in xcode 9 and already released a few versions to the store. Today I open the project for more developing, and I notice that I cannot see the files in the navigator. If I search for them I can go into them and edit. If I am running it, it builds and runs perfectly. Only problem is that I cannot navigate between files, and cannot find the storyboard in the search, so cannot open it at all.
I tried -
Hard clean
Delete derived data
reset computer and xcode.
But still cannot see the files in navigator.
Screen shot of navigator added:
As per our discussion in comments above I am adding the comment as answer, you can try deleting the xcuserdata folder inside .xcodeproj and re-run the pod install to solve the problem.
In order to do that, go to your .xcodeproj right click and select show package contents
Once it opens the finder window with contents inside it, simply delete the xcuserdata folder
Now get back to your project root folder in terminal and run pod install once done open the project using workspace.
That should solve your problem :)
Happy coding:)
I tried to remove test target from Xcode project so I followed suggestions from this Stackoverflow post.
Then I deleted AppnameTests folder with files in it (AppnameTest.m and info.plist) by right-clicking and choosing move to trash. Also tried Xcode->Edit->Delete for deletion.
After that, I tried to clean project, but one weird thing is happening. Folder AppnameTests is not removed after deleting that folder trough Xcode (files inside it are gone). It can be removed only manually using Finder, but I don't think this is a good idea, because maybe Xcode keeps reference to this folder.
I am using Xcode 6.1. Anybody experienced this? Why is this happening?
EDIT:
Here is what I see in finder after deleting (yellow) folder called AppnameTest using Xcode's delete command:
The folder itself from filesystem is not removed.
In Xcode, if the folder 'AppnameTests' is yellow, it is not a folder, it is a group. If it is blue, it is a real reference to a real folder.
In general, just after creating a new project in Xcode, this folder is yellow, and s it is not a folder, but a group that is a link to a folder (group has not necessary a corresponding folder in the Finder).
You can remove this folder by hand in Xcode (I do it regularly).
I was running my application without any problems on both the simulator and device. All of a sudden i get this error:
fatal error: file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UICollectionView.h' has been modified since the precompiled header '/Users/rashidasgari/Library/Developer/Xcode/DerivedData/ModuleCache/SWBH8ZAWBXAH/UIKit.pcm' was built
note: after modifying system headers, please delete the module cache at '/Users/rashidasgari/Library/Developer/Xcode/DerivedData/ModuleCache/SWBH8ZAWBXAH'
I tried any solution i could find and still no luck. Note that i tried running the application on another MacBook and everything works fine without any errors.
Cleaning the project is the first port of call (menu under Product).
If that doesn't help, delete the derived data. That can be done via the Locations section of the preferences or by navigating to the directory in Finder and deleting it (there is a little -> button in preferences to get there, or use Go To Folder... option in the Finder.
Ok after trying almost every solution on web, i decided to reinstall xcode and it finally worked.
I solved this problem by changing DerivedData folder name..see how i did
Xcode->preferences->Then you will be redirected to preferences screen
Then click on locations tab under menu selection->then you will have options like Derived data,snap shots ,archives
under Derived data you can see some thing like /Users/SENABI/Library/Developer/Xcode/DerivedData-> then click on that arrow button that's it there you can see DerivedData folder click on that and rename it. your error will be removed.
This is my experience and it worked for me hope it will be helpful to someone.
Error occurs when system header files are modified.
Solution :
If you have the backup of XCode then reinstall the XCode (Better solution).
Delete the DerivedData folder and then build the project
Use CMD+Shift+K to clean the build and then relaunch. This should solve the issue.
you don't have to delete anything.
you messed up a git pull somewhere probably. just quit Xcode and the simulator, reset any changes (or stash them) try another git pull, start Xcode again, clean your project and run it again.