41

It keeps saying:

fatal error: file '/Applications/Xcode5-DP5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/include/objc/NSObject.h'

has been modified since the precompiled header

'/Users/jackiexu/Library/Developer/Xcode/DerivedData/ModuleCache/2MWVPCGUMQ29P/ObjectiveC.pcm' was built

note: after modifying system headers, please delete the module cache at '/Users/jackiexu/Library/Developer/Xcode/DerivedData/ModuleCache/2MWVPCGUMQ29P'

1 error generated.

I must have deleted the derived data at least five times by now, and I'm getting nowhere. Any ideas?

Abdurrahman Mubeen Ali
  • 1,331
  • 1
  • 13
  • 19
Aeveus
  • 5,052
  • 3
  • 30
  • 42
  • This would happen if the time on your system is set back several years ago, to a date before the date when `NSObject.h` has been modified. – Sergey Kalinichenko Aug 31 '13 at 12:04
  • The time is still correct. – Aeveus Aug 31 '13 at 12:13
  • What is the mod date on NSObject.h? Maybe it's in the future. – JWWalker Sep 05 '13 at 23:04
  • 1
    Did you reinstall Xcode? – Scott Berrevoets Sep 05 '13 at 23:29
  • If you still have an Apple support case available in your Dev Licence, may be now is the right time to use it. Having said that, why the foundation header NSObject.h would be modified ? weird. – Alex Sep 06 '13 at 07:59
  • Have you used cmd-option-shift-k to try and clean the build folder? I'm wondering if this is something straight forward. Here is a related topic: http://stackoverflow.com/questions/5714372/how-to-empty-caches-and-clean-all-targets-xcode-4 – IanStallings Sep 10 '13 at 15:34
  • 1
    Strange enough reinstalling didn't work, however installing a newer version did. I was running XCode 5 DP-5, and tried everything, including manually removing the entire `DerivedData` directory. I eventually just downloaded XCode 5 DP-6, and the entire thing compiled smoothly. But now I still don't know what was causing the problem. – Aeveus Sep 10 '13 at 20:39
  • You should take a look at this post: http://stackoverflow.com/questions/15463179/how-to-fix-pch-error – Thomas Keuleers Sep 12 '13 at 13:59
  • You've been using a developer preview and the issue solved with an update. If the problem is not reproducible, then it could be a software issue combined with caching bugs. If you don't have an exact copy of the failing project that still fails with the old version but not the new one, then you'll probably never find the cause. – allprog Sep 12 '13 at 14:09

14 Answers14

61

Open a terminal and type in : rm -rf ~/Library/Developer/Xcode/DerivedData/ModuleCache/*

Clean your project and build again. Worked for me.

jverdi
  • 1,506
  • 13
  • 14
Neva
  • 1,330
  • 9
  • 11
16

Delete the folder, clean the app, restart Xcode if necessary.

coneybeare
  • 33,113
  • 21
  • 131
  • 183
12

as per xcode 5.

  1. click on Xcode preferences
  2. Goto locations tab
  3. click on the derived data path which navigates to the folder called DerivedData
  4. Delete the whole folder and restart xcode.

This works fine for me.

Happy coding :)

6

Have you tried reinstalling xcode? And have you cleaned using cmd+shift+k ?

Arbitur
  • 38,684
  • 22
  • 91
  • 128
6

The same thing was occuring to me. The warning was telling me:

After modifying system headers, please delete the module cache at '/Users/yunus.mehel/Library/Developer/Xcode/DerivedData/ModuleCache/13XL2DHZVON89'

So, I have restarted xcode, deleted derived data from Organizer, deleted derived data from the derivedData folder; none of them worked. Then I have realized, the solution was already there; go to:

"DerivedData/ModuleCache/13XL6DH2BON89"

and delete that folder, not the "DerivedData/<your_project>". Make a clean build, it will work again.

Abdurrahman Mubeen Ali
  • 1,331
  • 1
  • 13
  • 19
Yunus Nedim Mehel
  • 12,089
  • 4
  • 50
  • 56
4

Run this script to delete all relevant files in /Library/Developer/Xcode/DerivedData and /var/folders:

# run with
# ruby reallyCleanXcode.rb
derivedDataFolder = Dir.glob(Dir.home + "/Library/Developer/Xcode/DerivedData/*")
moduleCache = Dir.glob("/var/folders/**/com.apple.DeveloperTools*")
FileUtils.rm_rf derivedDataFolder + moduleCache
Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
orkoden
  • 18,946
  • 4
  • 59
  • 50
2

This happen when compiling, when running the app or neither?

Have you tried this:

Build Settings - Build Locations - Precompiled Header Cache Path -- there's a folder... delete it.

Sophy Swicz
  • 1,307
  • 11
  • 21
1

I solved this by:

Quit restart Xcode + clean project + clean build folders + clean derived data + deleted the /var/folders/.../.../C/com.apple.DeveloperTools/5.0.2-5A3005/Xcode/SharedPrecompiledHeaders + unplugged my iPhone

Rebuild and works :)

Van Du Tran
  • 6,736
  • 11
  • 45
  • 55
  • Thanks for the pointer to /var/folders. I was running into this with one of *our* frameworks, and cleaning out ...DeveloperTools/6.2/Xcode/... was what fixed it. – Dan Jackson Mar 27 '15 at 17:07
0

I was having the same problem. I did SHFT+CMD+K and tried to run,again the error appeared. My error pointed to the NSJSONSerialization header file. So what I did is deleted the files in ModuleCache and the project seems working now. I had changed my code which used NSJSonSerialization thinking it to be wrong, and project started working with the code also :)

To delete the files -- Click on 'Go' in the Desktop and then 'Go to folder' then type the folder path (Eg : 'Library/.…./ModuleCache') and delete all the files.

Regards, ASK

ASK
  • 11
  • 2
0

Please follow below steps to get rid from your problem.

"Library/Developer/Xcode/DerivedData/ModuleCache/"

Delete all Folders inside ModuleCache Folder.

Make a clean build, quit Xcode and run it again

sure ,it will work fine.

Good Luck !!!

Dipak Narigara
  • 1,796
  • 16
  • 18
0

I used Shift + CMD + K to try and clean the project, but it did not disappear.

All I had to do was go and check the names of <yourProjectName>-info.plist and <yourProjectName>-Prefix.pch.

Then Shift + CMD + K worked.

In my case the problem was Clang exiting with code 1.

Qantas 94 Heavy
  • 15,750
  • 31
  • 68
  • 83
0

my solution,

in terminal, run command:

rm -rf /Users/jackiexu/Library/Developer/Xcode/DerivedData/ModuleCache/2MWVPCGUMQ29P

then in xcode, clean then restart xcode and build

andrewchan2022
  • 4,953
  • 45
  • 48
0

In addition to all of the other "clean your build" answers, nothing was working for me until I emptied out the (highly undocumented!) /var/folders directory.

Apparently, this is a "miscellaneous caches" dir maintained by OS-X. I didn't even bother figuring out what were "the correct files"; I just cleaned out the entire directory.

...And now I can build again. Hooray! From terminal:

[sudo] rm -rf /var/folders/*

(Although I did it from Finder, via authentication.) (OS-X 10.9.latest)

Additional clue: I could build with XCode-6-beta, but got the goofy corrupt error in XCode-5.

Olie
  • 24,597
  • 18
  • 99
  • 131
0

I was facing the same issue. I first cleaned the project do this by hitting "shift + command + k" and just rebuilt the project and it worked for me. hit "command + B" to rebuilt your project