Xcode 4.1 fatal error: stdlib modified since the precompiled header was built
Asked Answered
N

11

73

Building an iPhone app, using:

  • Xcode 4.1
  • Base SDK iOS 4.3
  • Apple LLVM Compiler 2.1

I have started getting the following error:

fatal error: file '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/../lib/clang/2.1/include/stdint.h' has been modified since the precompiled header was built

I have tried reinstalling Xcode and OS X - no luck. What's causing this?

Nitrification answered 15/8, 2011 at 22:25 Comment(1)
See my answer here: link I hope it will help someone :).Shavonneshaw
I
152

First try a clean build via the Product -> Clean menu (as of XCode 4.6.2).

If that still doesn't work then open the Organizer (from the menu select Window->Organizer). Once the Organizer is open, select Projects from the toolbar at the top of the window. On the left is a list of projects, select the one you are having a problem with.

The details panel (to the right of the list) will display the project name, location, status. The row beneath that shows where the Derived Data is located. Click the Delete... button the far right. A dialog will appear, click Delete.

You can also manually delete the Derived Data:

~/Library/Developer/Xcode/DerivedData/{project name + gobly-gook}

This directory contains built products and indexes for the project. It is OK to delete it because it only contains items generated by Xcode. Xcode will regenerate everything next time the project is opened.

Indre answered 16/8, 2011 at 0:10 Comment(7)
Or you can simply "touch" your .pch file (or add and remove a char in it) so that it is recompiled, without the need to clean and rebuild all your project (this way the next build is quite faster)Mesoderm
With older versions of Xcode this was the only way to fix it.Indre
I had to also delete the Modules/&App dir under DerivedData after I changed a system header (accidentally).Orangewood
@Mesoderm when u say touch .pch, that just work because it is just the way to recompile entire project (which can be achieved by recompiling) as .pch is imported to all the class by default, thus touching it make entire project compile all over.Tillis
@Tillis That's only true if you have one target and one project in your workspace. I usually have multiple projects, each one having its own .pch file; I don't want to "clean" and have all my projects (like my Pods) in my workspace recompile. Just changing the .pch of my app will only recompile all the files of my app, but not the external libraries (like my CocoaPods) and any other projects in my workspace. That's why for this particular issue I prefer to try and touch the .pch first, and only clean or remove DerivedData if the two former solutions do not work.Mesoderm
First just clean Product - CleanBistort
OSX 10.10.2/Xcode 6.2. I was looking around in NSMutableArray.h for a method, and subsequently when I tried to Build my project, I got that error. I guess I must have changed something accidentally. My current project wouldn't build, no old projects would build, and a new project wouldn't build. No amount of cleaning worked for me, and going into the Organizer and deleting didn't work either. What worked for me was: 1) $ cd ~/Library/Developer/Xcode/ 2) Then deleting the whole DerivedData folder: ~/Library/Developer/Xcode$ rm -rf DerivedData.Lientery
C
76

I was able to fix it in a much easier way, by simply choosing Product > Clean, then Product > Build from the Xcode menubar.

Claptrap answered 12/3, 2012 at 20:8 Comment(2)
+1. Did the same but a "deep clean" by pressing Cmd + Opt + Shft + KQuincey
Please note that you will have to do Clean and Build on each target device that gives you the error. I had to do it for my simulator and for my iPad.Gynous
B
37

Deleting the DerivedData folder did not work for me when Archiving.

I had to look at Build Settings - Build Locations - Precompiled Header Cache Path and delete that folder.

For me that was:

/var/folders/_w/t0mj70hd1439tqgxff7_mtt00000gn/C/com.apple.Xcode.501/SharedPrecompiledHeaders
Blume answered 12/9, 2011 at 0:21 Comment(2)
This folder worked for me too. Although I did previously delete the ~/Library... folder.Rego
I've just noticed that this folder is in the build settings. It's called Precompiled Header Cache Path!Blume
C
16

I thought I would add a separate answer rather than a comment to Cryptognome's answer, because it is in fact a different solution when the issue comes from running xcodebuild. Like Cryptognome, I had the error come up with the command-line tool xcodebuild. As an alternative to manually going into the /var subfolders, I found that I could set my own cache for the shared PCH, which you can do by setting the environment variable SHARED_PRECOMPS_DIR, e.g as follows

xcodebuild -target Foo -configuration Release SHARED_PRECOMPS_DIR=/tmp/foo/SharedPCH

This way, I never get the error in automatic builds.

Note in the above command, I would also typically set the OBJROOT and SYMROOT env var to build also in /tmp. At the end, I clean things up.

Condign answered 2/11, 2011 at 3:25 Comment(1)
For me, using xcodebuild clean build made the build work again.Mage
C
4

The xcodebuild command line tool sometimes fails with this error. This happened to me when I synched an svn workspace to an earlier build. The xcodebuild tool keeps its precompiled headers in the folder Ants mentioned:

/var/folders/... scrambled eggs .../-Caches-/com.apple.Xcode.503/SharedPrecompiledHeaders/

You have to look in the build command itself to see the actual folder name (-include /var/...), but it may be using several if you're building for different architectures (arm6, arm7, simulator, e.g.) So if you're having this problem with a command line build, just delete everything in /var/.../SharedPrecompiledHeaders.

Churinga answered 5/10, 2011 at 19:43 Comment(1)
That was the issue I had as well. Rather than relying on this default cache folder, I set my own cache in the same /tmp subfolder I used for the automatic build, which you can use by passing e.g. SHARED_PRECOMPS_DIR=/tmp/foo/SharedPrecompiledHeaders as an argument to xcodebuild. This way, I never get the error in automatic builds.Condign
G
3

Remove the contents for the Simulator by iOS Simulator > Reset Content and Settings... and hit Rest. This will remove any existing pre-compiled instances of the headers and resources. This worked for me

Galenical answered 15/8, 2012 at 14:45 Comment(0)
C
3

Solution:

1)Product->Clean

2)Product->Build

Error Type:

a kind of Build error

One of the causes:

one might have changed the framework file. This sometimes happens when a change is made to a framework that another framework depends upon. The precompiled header cache gets out of sync, and Xcode is unable to compile the given project.

One of the Scenarios:

one might have chosen Jump To Definition and did some change after selecting a framework control.

Coulter answered 1/8, 2013 at 8:41 Comment(2)
Sure enough, I edited a System header file, which was listed in the error message. I was able to Time Machine restore the header, then clean and build, with success.River
it's really good solution otherwise one would have to do the aforementioned steps on every project in the system.Coulter
M
1

I was able to get rid of this error simply by cleaning (command+shift+K) and rebuilding.

Moton answered 31/5, 2013 at 19:13 Comment(0)
G
1

I tried above all but no use. Finally I deleted Xcode and re installed again. Now it is working fine..

Xcode->delete->install again

It might help some one...

Gerome answered 28/8, 2014 at 2:46 Comment(0)
R
0

I had this error on cordova when I ran : cordova run ios

fatal error: file '/Users/.../cordova/platforms/ios/CordovaLib/CordovaLib_Prefix.pch' has been modified since the precompiled header
  '/var/folders/gb/3cf6hy4x7z3d7hprls6xmd0m0000gr/C/com.apple.DeveloperTools/6.0-6A313/Xcode/SharedPrecompiledHeaders/CordovaLib_Prefix-bfgesbulnxtdepfwgniffeysypgv/CordovaLib_Prefix.pch.pch' was built
note: please rebuild precompiled header
  '/var/folders/gb/3cf6hy4x7z3d7hprls6xmd0m0000gr/C/com.apple.DeveloperTools/6.0-6A313/Xcode/SharedPrecompiledHeaders/CordovaLib_Prefix-bfgesbulnxtdepfwgniffeysypgv/CordovaLib_Prefix.pch.pch'
1 error generated.

** BUILD FAILED **    

The following build commands failed:
    CompileC build/CordovaLib.build/Debug-iphoneos/CordovaLib.build/Objects-normal/armv7/NSDictionary+Extensions.o Classes/NSDictionary+Extensions.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    CompileC build/CordovaLib.build/Debug-iphoneos/CordovaLib.build/Objects-normal/armv7/CDVInvokedUrlCommand.o Classes/CDVInvokedUrlCommand.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler

I tried with clean and build but doesn't work, finaly I removed the folder '/var/folders/gb/3cf6hy4x7z3d7hprls6xmd0m0000gr/C/com.apple.DeveloperTools/6.0-6A313/Xcode' and works! This tip, may be help others

Riemann answered 8/10, 2014 at 18:51 Comment(3)
A folder with a path like that seems like a painfully too-narrow example. It might be better to say "I finally removed the offending folder from the error, and it worked."Tremain
Yeap, you are right, but I don't found other case like mine, so I think it can be useful for othersRiemann
Exactly my point--if one takes your answer literally they'll wonder "why can't I find this path?" when the thing to take away from this is "I deleted the directory tree containing the precompiled headers (whatever that may be for you) and it worked."Tremain
N
0

Clean ways are not working for me, eventually I solved this issue by reinstall XCode.

Noddy answered 17/12, 2014 at 6:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.