ChatGPT解决这个技术问题 Extra ChatGPT

fatal error: malformed or corrupted AST file - Xcode

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!

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

E
Elias Zamaria

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).


Thanks devgeek. Your tip worked, but I had to do a Product > Clean after as well, for anyone else who has this issue.
Worked for me as well. Thanks very much! No clean required here though.
For me I only needed to clean
Thanks man, this worked. But can you please explain what is all this about_ I like to know why something happens, when it does. And I just had this error when I opened my project the next day, out of the blue.
clean up build folder would resolve the issue as well. (project > press option & select clean build folder)
N
Nitesh Borad

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


Pressing the Alt key while navigating to 'Product' will give you 'Clean build folder' - solved for me.
S
Subathra D

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


M
Muzammil

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

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

This will open direct xcode folder inside hidden library folder.

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

Now run XCode again, all will fix.


A
Ahsan Ebrahim

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

Product-> Clean

or press

command+shift+K


W
Walt Sellers

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:

Quit Xcode 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.


B
BryanH

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

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


h
hiroshi

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.


H
Hlung

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


D
Devashis Kant

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


P
Pascalius

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


T
TobiaszParys

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


d
dmuchowski

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"


S
Stan Tatarnykov

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)


y
ykonda

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...


u
user9527

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.


O
Onichan

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.


C
Community

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.


C
Cyrus Zei

if you can't find your "Derived data"

File -> Workspace settings Click on the arrow icon next to your path Remove "Derived data" folder


u
user2820855

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!


What solution does this provide to the OP?
@Rambatino, well.. no answer but at least hes telling people not to reinstall xcode.
@mihai, In fairness, if you never want to experience fatal errors with Xcode, uninstalling will solve that ^^
@Rambatino, you're right, but for this issue reinstalling is overkill and doesnt fix the problem so it is a bit helpful of an answer. This answer should have been a comment instead stating, reinstalling XCode doesnt fix it."