118
votes

I get this error when building my app in the latest version of Xcode:

fatal error: malformed or corrupted AST file: 'Unable to load module "/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache/XYZYIE6ZV0OP/Darwin.pcm": file not found' note: after modifying system headers, please delete the module cache at '/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache/XYZYIE6ZV0OP' 1 error generated.

When I navigate to:

/Users/me/Library/Developer/Xcode/DerivedData/ModuleCache

I can see that the directory 'XYZYIE6ZV0OP' doesn't exist.

Does anybody know how I can resolve this? I cannot delete anything at the directory as suggested in the 2nd part of the error message as that directory doesn't exist!

20
Product > Clean is good, but for me this helped: stackoverflow.com/questions/20014235/…CoolMind

20 Answers

335
votes

Had same problem. Clearing derived data folder solved the issue for me. In Xcode, go to Window->Organizer->Projects, select your project, and press the "Delete..." button next to "Derived data".

If this doesn't work, you can try to do a Product->Clean (Cmd+Shift+k).

37
votes

Press Command + shift + k or clean the project and then run project...

13
votes

In Xcode select Product-->Clean problem will be solved

9
votes

By default Library folder is hidden in Mac. Best way to navigate to that folder is :

  1. Open Finder
  2. Select Go from menu -> Select "Go to folder"
  3. Type : /Users/"your user name"/Library/Developer/xcode

This will open direct xcode folder inside hidden library folder.

  1. Select "DerivedData" folder
  2. Command + A, select all and delete them.
  3. Open Simulator and "Reset Content and Settings".

Now run XCode again, all will fix.

3
votes

I had the same issue, solved it by cleaning the project.

Product-> Clean

or press

command+shift+K

2
votes

In my case, I accidentally modified NSURLConnection.h. Xcode complained about cache at path

/var/folders/p6/fk2rmf017sn2d_gds6dtqr6hrst8b2/C/com.apple.DeveloperTools/5.0.2-5A3005/Xcode/5.0.2-5A3005/Xcode/ModuleCache/XWWWZ5ED888F

I finally found the steps to fix it:

  1. Quit Xcode
  2. Delete the upper "5.0.2-5A3005" at /var/folders/p6/fk2rmf017sn2d_gds6dtqr6hrst8b2/C/com.apple.DeveloperTools/5.0.2-5A3005

When Xcode restarted, it regenerated that folder and everything in it.

2
votes

I had the same issue ever since installing the latest SDK.

My solution was to delete the derived data and clean the project.

1
votes

I got same error on executing xcodebuild command of Xcode6-beta5.app coexisting with Xcode.app (Xcode 5).

In this case I added -derivedDataPath to separate ModuleCache from the one for default Xcode.app.

  xcodebuild -derivedDataPath ./build/Xcode6-beta5/DerivedData ....

This works for me.

1
votes

I tried deleting derived data and Clean project several times and it doesn't work. The file in my warning is an old file I already deleted from Project Navigator and all the Build Settings. But it keeps showing up and gives me this error. The error only occurs on Simulator, but not on device. Which is really really weird. :/

For some reason, I switched branch to some other branch and switch back and it works again. If anyone even know how that could work please tell me :D

1
votes

Simply clean remove the Derived Data and build folders. The problem shall be resolved.

0
votes

In my case the SSD was broken. You can verify the disk with apples Disk Utility

0
votes

In my case I had a spaces in my plist file name.

I removed it, and changed Info.plist File key in target Build Settings

0
votes

Refreash Safari browser, scroll down the page and you will see you "Click + button for add build ..." then add actual build, click Save and "Waiting for Review"

0
votes

Cleaning the project and deleting the drive data didn't fix it for me. But what finally fixed it was changing the model of simulator that I used.

So first do a clean, then if you were running it on iPhone 5 simulator, run it on iPhone 5s simulator to fix the issue. basically, run it on any other simulator other than the one you were running.

(Credit to Hlung for his answer, I hope this one is a bit more clear)

0
votes

If you have your project scheme set to "Wait for executable to be launched" this error might happen.

In that case, just changed your scheme from Product > Scheme > Edit Scheme...

0
votes

In my case, I tried to archive a app in one project within a xcodeworkspace

close Xcode, the open the single target project, and clean an Then, I do archive, it makes an iOS App archive.

I hope I can help someone.

0
votes

Got this error while trying to build a third-party app for the first time. Adding foundation as a library fixed the issue for me.

0
votes

I did Clean cached, Delete derived data, Manually delete the Module cache folders which found from the error logs, Restart xcode, Restart machine. But non of them helped me.

But this steps help me to resolve the issues

  • Comment out all the #import line in [Name]-Prefix.pch files.
  • Build, as expected its pointing me to different errors.
  • Revert back the changes I have done in [Name]-Prefix.pch and Build, compilation succeeded.

This solution help me to resolve the issue.

0
votes

if you can't find your "Derived data"

  1. File -> Workspace settings
  2. Click on the arrow icon next to your path
  3. Remove "Derived data" folder
-6
votes

tried to re-install XCode which didnt resolve the issue, also created a new local user account & get the same error so in the end I gave up & restored to a time machine backup from a few days before... seems to be ok again... for now!