54

I was recently working on my application messing around in the info.plist section, and since that my application will not run on my test device:

file 'project.pch' has been modified since the precompiled header was built

Something to note is that the app runs fine in the simulator.


Edit: Now I am getting this error instead of the other one:

No such file or directory (/Users/Me/Library/Developer/Xcode/DerivedData/MyProject-abcdefghijklmnopqrstuvwxyz/Build/Products/Debug-iphoneos/MyApp./MyApp)

No such file or directory error

How to regenerate the info.plist file?

Cœur
  • 37,241
  • 25
  • 195
  • 267
user1542348
  • 583
  • 1
  • 4
  • 6
  • Similar answer on here that solved it for me (and actually explained where the PCM files are)... http://stackoverflow.com/a/25182895/1861181 – Morkrom Sep 18 '14 at 18:33

21 Answers21

104

You could try a deep clean (not the same as Product > Clean) - Option+Command+Shift+K

Note: this means the clean the build folder (by pressing Option + Product -> clean folder)

Cœur
  • 37,241
  • 25
  • 195
  • 267
HexAndBugs
  • 5,549
  • 2
  • 27
  • 36
  • I had this happen to me, building my Mac OS X app: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h' has been modified since the precompiled header was built 1 error generated. Wow! Indeed, all of the files in have a mod date of 2 days ago. Huh? I had updated to an Apple developer seed of Mac OS X, but that was about 3 hours before 10:15. flightplanner's deep clean fixed the error. Mysterious! – Jerry Krinock Apr 22 '13 at 15:21
75
  1. Close your project or workspace.
  2. In Finder: ⇧shift+⌘cmd+G
  3. Paste: ~/Library/Developer/Xcode/DerivedData/
  4. Delete the ModuleCache folder and empty trash.
  5. Open up your project.
  6. Clean: ⇧shift+⌘cmd+K
  7. Build: ⌘cmd+B
emotality
  • 12,795
  • 4
  • 39
  • 60
  • 7
    I deleted the ModuleCache folder and it seems to work. – DrFloyd5 Sep 19 '14 at 22:06
  • 2
    Deleting all the contents inside ModuleCache worked for me too. – JRam13 Oct 20 '14 at 14:27
  • 1
    I was having a similar problem with an sdk 10.10 file supposedly being modified. Wiping out all the files in the cache fixed the problem – markhunte Nov 29 '14 at 18:43
  • 1
    When searching, change the selected button from This Mac to "ModuleCache" and things will be much faster. – funroll Jan 05 '15 at 16:47
  • Thanks alot. It did work. Small add on we need to close all xcode projects before deleting module cache. Otherwise that folder will reappear then and there. – Karan Alangat Apr 28 '15 at 10:59
  • Thats what needs to happen. Xcode generates new necessary files and folders that works perfectly with the new version. – emotality Apr 28 '15 at 11:02
  • 1
    Worked for me too, tho DerivedData was located in my project directory. I'm using Xcode 6.3. My problem was caused by changing the name of my directory where my project was located. – chow Jun 23 '15 at 12:58
  • Go to Xcode->Preferences -> Locations -> Click arrow in front of DerivedData, delete every thing. – AsifHabib Jul 15 '15 at 21:08
60

In my case the error message had a small hint:

note: after modifying system headers, please delete the module cache at '~/Library/Developer/Xcode/DerivedData/ModuleCache/5CYAJ91AZCB7'

I tried and it worked.

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
CedricSoubrie
  • 6,657
  • 2
  • 39
  • 44
  • Thanks for this answer Cedric. ONLY this solution worked for me in Xcode 5.1/iOS 7.1! – codeburn Apr 26 '14 at 12:12
  • 8
    This was the only answer that worked for me with the Xcode6-Beta! Thanks! – johnboiles Jun 10 '14 at 18:34
  • If you accidentally modify a system header this is the only way to get your project to build again. The fact that you can command click any system element and then modify it is quite a ridiculous "feature" Xcode has. There should at least be some kind of warning or something before it lets you edit them. :/ – Pamelloes Jun 21 '14 at 04:58
  • 1
    The same issue with XCode6 was fixed with this answer. Thanks man! – Anton Ogarkov Sep 18 '14 at 14:50
  • This solved my problem, but I noticed that the directory for the module cache was inside my project directory (in the `build` directory) as opposed to in the ~/Library directory. If anyone keeps having that issue, check to see in the error output where that directory is for your project... – KellyHuberty Sep 24 '14 at 16:41
  • xcode 6.0 (6A313) asked me to rebuild the derived data, however deleting it and cleaning the project didn't help - I had to do it manually, and then it worked. – Chris Oct 05 '14 at 07:41
43

Simply touching the project's pch file solved this issue it for me :

touch Test.pch
ıɾuǝʞ
  • 2,829
  • 26
  • 38
  • @kenji thanks! We have a huge project which started failing on Jenkins because of this. Made a [script](https://github.com/markohlebar/touch-pch) to fix it, you can put this in your build phase or whatnot. – Marko Hlebar Sep 20 '14 at 19:17
  • 2
    It's odd that this worked for you guys. Touching the .pch should change the timestamp, which is precisely what the xcodebuild error is complaining about! – Rembrandt Q. Einstein Sep 30 '14 at 17:15
  • After wasting one and half day finally your solution worked for me. Damn man, you are the saviour. Thanks – Anuran Barman Jul 23 '21 at 11:02
19
  • Product -> Clean
  • Product + Option -> Clean Build Folder
  • Close Project or Workspace
  • Clean 'ModuleCache' path in Finder.

Worked for me in Xcode6 GM and iOS 8.0.

Jorge SV
  • 349
  • 8
  • 10
  • It works for me, since i replace the Xcode 6 with Xcode 6.0.1 – yuhua Sep 18 '14 at 06:56
  • 1
    Yes, Xcode 6.0.1 broke my build scripts. I wonder if in previous Xcode installations they automatically removed the ModuleCache folder? I had to manually remove it from the location mentioned in my failed build.log. For me this was at: /var/folders/b1/s0pj4gvn3cq589pjwdkcx_b80000gn/C/org.llvm.clang – Shawn Sep 22 '14 at 18:05
11

When the .h file of a Library Provided with Xcode is changed (even a space), this error could occur.

The following maybe tried in order to fix this issue

  • In, Project -> Build Settings, change Precompile Prefix Header to NO

    OR

  • Run rm -rf ~/Library/Developer/Xcode/DerivedData and Clean Build

Community
  • 1
  • 1
Abhilash Gopal
  • 429
  • 5
  • 8
7

I constantly had this since upgrading from Xcode 4.6 to Xcode 5 with iOS projects when using command line build (xcodebuild).

What worked for me is to use this as command line build command:

xcodebuild -project path/to/my.xcodeproj -configuration Debug clean build

Before this, I've tried:

  • Clean the project in Xcode GUI.
  • Delete the offending pch file.
  • Delete the offending pch file's parent folder.
  • Delete the DerivedData project folder.

None of the above worked for me under Xcode 5.0.2, Mavericks, iOS7.

Note that the problem didn't happen to me when using Xcode GUI.

kakyo
  • 10,460
  • 14
  • 76
  • 140
5

I just go to directory "/$HOME/Library/Developer/Xcode/DerivedData/", delete everything there

0oneo
  • 695
  • 7
  • 10
3

Just Click Product from the menu and select Clean

Product>Clean

Worked fine for me.

M_R_K
  • 5,929
  • 1
  • 39
  • 40
2

I got the same problem. My error said like I need to delete the cache in the below locaition,

Users/myusername/Library/Developer/Xcode/DerivedData/ModuleCache/3FGETKFCU0N0W

3FGETKFCU0N0W was a folder, when I deleted it and then clean build the project. Then the error disappears.

Easwaramoorthy Kanagaraj
  • 3,925
  • 8
  • 36
  • 62
2
rm -rf ~/Library/Developer/Xcode/DerivedData/
Rudolf Adamkovič
  • 31,030
  • 13
  • 103
  • 118
2

If you use AppCode you can try remove content form: /Users/[Username]/Library/Caches/appCode30/DerivedData/

Worked for me :)

lembrykos
  • 21
  • 3
1

For me, this problem is only occurring in Xcode 6 beta version, So I switch back to Xcode 5, and now problem is solved.

I tried all the steps suggested by all users here, but no one worked for me.

So, if you have both versions of Xcode and have issue only in Xcode 6 beta, then switch to Xcode 5 and clean the project, problem will be solved.

Nitesh Borad
  • 4,583
  • 36
  • 51
1

Also, just open terminal, and delete the .pcm file that has been generated (Xcode 6 onwards)

rm <path-to-pcm-file>
Abhilash Gopal
  • 429
  • 5
  • 8
1

If you get this when switching between git branches, try adding this post-checkout hook which will clean your project every time you change branch.

!/bin/sh
xcodebuild clean -configuration Debug

Save as .git/hooks/post-checkout relative to your project root and don't forget chmod +x .git/hooks/post-checkout

Maciej Swic
  • 11,139
  • 8
  • 52
  • 68
0

I tried these one by one but failed to build and run my project. So I changed Precompile Prefix Header to NO as mentioned by @Abhilash Gopal, then I reset the simulator,deleted the derived data, removed the corresponding .pcm file(In my case it was the UIImage.h from UIKit framework, so removed the UIKit.pcm).Then I cleaned the project and only then I was able to build it successfully. In earlier versions of Xcode these files were locked basically and were not allowed to edit. But its not the case now. Hope this helps someone who face the same situation.

Meera
  • 1,031
  • 6
  • 25
0

The only solution there worked for me was running the following command:

sudo rm -R /var/folders/

But that gave me a lot of troubles in OS X.

I thought because /var/folders/ is for temporary files it should be okay to just empty anything in it. But I was wrong see the following post: link

And the problem you described occurred every-time I tried to build my Xcode project - I'm building it from the CLI though Jenkins.

Which means I couldn't run the rm command every-time. So I found some inspirations and wrote the following ruby script which solved my problem:

#!/usr/bin/env ruby

require 'fileutils'

cache = Dir.glob("/var/folders/**/com.apple.DeveloperTools*")
FileUtils.rm_rf(cache)

I hope it would be helpful to someone.

Community
  • 1
  • 1
martinmose
  • 443
  • 8
  • 12
0

Deleting project.xcworkspace did a trick for me.

project.xcworkspace is a directory which describes schema of current Xcode workspace state. Each time Xcode is launched it will regenerate project.xcworkspace if not exist already.

In order to delete project.xcworkspace:

  • Right click on your project file yourProject.xcodeproj
  • From drop-down menu choose Show Package Content
  • Purge xcworkspace file
Delorean
  • 356
  • 3
  • 11
0

If you are building on command line using xcodebuild remove '-parallelizeTargets' option passed to the command. That fixed the issue for me

dev
  • 2,180
  • 2
  • 30
  • 46
-1

After going through a lot of answers and helpful suggestions, I found out the solution to be: Uninstall Xcode 6 and reinstall it through the available dmg file and then install all the components for Xcode.

Product + Option -> Clean Build Folder, Clean Build Project, Deleting Module Cache files and Derived data files, using touch .pch, deleting pcm file, using command line to remove var/folders (Surprisingly, all of this did not help in my case)

Was stuck at it for more than 3 hours before finding the solution. Hope this helps someone.

Thanks.

Som
  • 122
  • 1
  • 1
  • 12
-1

Just open terminal and fire below command:

rm /Users/pratik/Library/Developer/Xcode/DerivedData/ModuleCache/LKL48GNAN6S7/UIKit-2X95M2Q1NPNPL.pcm

give your file path which return .pcm error. and then Clean Project and Run...Enjoy!!!

Mayank Jain
  • 5,663
  • 7
  • 32
  • 65
Pratik Patel
  • 1,393
  • 12
  • 18
  • 2
    Please explain: What does this command do and why does this solve OP's problem? – TobiMcNamobi May 22 '15 at 10:15
  • sure, basically this command will remove tmp file that was created ModuleCache. When you save any UIKit or any default framework file then it creates a tmp file that don't allow to build your project. Need to remove that tmp (.pcm) file and then clean your project and build. – Pratik Patel May 23 '15 at 06:01