Malformed or corrupted AST file
As requested:
What caused this error for me (after getting the new Xcode) was I would try to run a project in simulator (accidentally in simulator, I never use simulator), but I'd forget to select my device or my device would become unplugged without me noticing, and it will try to run in simulator... so I would get those classic ".o" file errors... Then I would switch back to my device and get corrupt AST files...
To CURE the problem... (Follow the steps below VERY closely!!!!!)
- Clean your project
- QUIT Xcode (CMD+Q)
- Run this Terminal Command:
rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache/*
- Run this Terminal Command:
rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/*
- Reopen Xcode
- MAKE SURE YOU HAVE YOUR DEVICE SELECTED AND NOT SIMULATOR
- CLEAN project (Yes, again)
- THEN build (to your device, not to simulator)...
Enjoy!
Note: After further experimentation I've found that the force-quitting of xCode is possibly not necessary.
Package.resolved file is corrupted or malformed
I tried the solution suggested by Maxwell above but it didn't resolve the problem for me.
The error appeared with Xcode 12 but upgrading to Xcode 13 didn't fix it either.
Instead, I decided to take Xcode at its word and delete the Package.resolved file. But where is it? I did this:
In Finder, tap Shift+Cmd+. to reveal hidden files and folders.
The Package.resolved file is inside your .xcodeproj directory at [appName].xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Right click on .xcodeproj and project.xcworkspace to show package contents.
Move the Package.resolved file to the bin, and then empty the bin.
Reopen Xcode and open your project again. This gave me another error:
the package at '/' cannot be accessed (Couldn’t read '4.5.0':In Xcode, File / Packages / Reset package caches.
The Swift Package Manager starts working on this.Rebuild the project. The error had gone and my project rebuilt successfully.
Good luck!
Related Topics
Allow Unverified Ssl Certificate in Uiwebview
Warning Frame for "Navigation Bar" Will Be Different at Run Time Appears in Xcode 8 Swift 3
Switching Viewcontrollers with Uisegmentedcontrol in iOS5
How to Get Core Data Object from Specific Object Id
Code Signing Is Required for Product Type Unit Test Bundle in Sdk iOS 8.0
iOS 7 and Later: Set Status Bar Style Per View Controller
Email & Phone Validation in Swift
Development Team Not Showing in Xcode
Back Button Callback in Navigationcontroller in iOS
How to Add Older Version of iOS Sdk in Xcode 4.5
Coremotion Updates in Background State
iOS 9 "Fbauth2" Missing from Info.Plist
iPhone Sdk Internet Connection Detection
How to Scale a Uibutton's Imageview
Swiftui - Animations Triggered Inside a View That's in a List Doesn't Animate the List as Well
Hide Device Volume Hud View While Adjusitng Volume with Mpvolumeview Slider