Xcode version 4.6.2 (4H1003) compiler error
Solution 1
Do a Clean of the project; hold Option so that you are cleaning out the whole build folder and intermediates. You might have to quit Xcode and throw away the whole contents of the DerivedData folder by hand in the Finder, as I describe here: How to Empty Caches and Clean All Targets Xcode 4
Solution 2
Go to your project's Build Settings
, find a setting named Precompiled Headers Cache Path
, then delete that folder
Solution 3
Do a cleanup using command+shift+k
and run existing project again.
Solution 4
From XCode 4.6.2 Release Notes
Known Issues
Building
When building a product previously built with Xcode 4.6.1 or earlier, the build fails with an error similar to this one:
PCH file built from a different branch ((clang-425.0.27)) than the compiler ((clang-425.0.28))
To address this issue, choose Product > Clean before building your product. 13663167
Performing Product > Clean works
Solution 5
I've tried all the above and it works fine from Xcode UI, but it was still failing for me when I ran xcodebuild from command line.
That was due to dependencies to other libraries and their pre-compile headers. When running from command line, looks like xcodebuild store/reads pre-compiled headers from here:
/var/folders/v0/ztxy9kls7sv05dpmvjgg_xwr0000gn/C/com.apple.Xcode.501/SharedPrecompiledHeaders
After cleaning up that folder, xcodebuild succeeded.
OscarTheGrouch
Updated on June 16, 2022Comments
-
OscarTheGrouch almost 2 years
I just updated to Xcode version 4.6.2 (4H10003) and tried to run a previously working application project in the simulator and received the following error and the build failed.
PCH file built from a different branch ((clang-425.0.27)) than the compiler ((clang-425.0.28))
What went wrong and how can it be fixed?
-
zingle-dingle about 11 yearsYes, a clean worked for me also. The error is just saying that the pre-compiled headers was built with a different version and is not compatible with the newest compiler version.
-
matt about 11 yearsIf this hasn't happened to you on previous Xcode upgrades, you were just lucky. It's happened to me. You get used to it after a while...
-
Luke about 11 yearsThis worked for me after doing the 'Clean Build Folder' with option held down. Thanks!
-
A-Live about 11 yearsYes it was a problem with previous versions but it's acknowledged to worth be mentioned at the release notes only now. Also, they give no solution for people not using Xcode as IDE, @sycx does (clear Precompiled Headers Cache Path).
-
Orange about 11 yearsOnly this action helped me with mentioned problem. Thanks!
-
OscarTheGrouch about 11 yearsThis worked for me thanks...I didn't know holding the option does a different kind of clean.
-
Greg Combs about 11 yearsThis folder location will be different for everyone, so a quick way to locate the right folder to clean is to use a find+grep ... sudo find /var/folders | grep SharedPrecompiled
-
Jeff about 11 yearsI had the same problem. Running from the command line failed, even though I could build from within Xcode. I ended up running:
sudo find /private/var/folders -name SharedPrecompiledHeaders
and then emptied out the resulting directories. Worked like a charm. -
Jeff about 11 yearsThis only works for building within Xcode. If you're building from the command line, see Rodrigo Lima's post below.
-
John Bowers almost 11 yearsIf I could give this an additional upvote I would. Definitely cleaning doesn't seem to work from me when building from the command line. I expected that it would, but knowing where to look for the precompiled headers was very helpful.
-
RedYeti over 10 yearsGreat answer! But I had no such folder at that location (even at at Terminal prompt using ls -lAhF). However closing Xcode and then deleting the com.apple.Xcode.501 folder worked just fine.
-
RedYeti over 10 yearsDidn't work for me - however the extra step given by @karim's did (find and delete the folder in the "Precompiled Headers Path").
-
karim over 10 yearsThe exact location of precompiled header can be found in the project, part of the folder path is random (I guess), esp after /var/folders/xx..xxx/C.
-
RedYeti over 10 yearsSorry - I wasn't clear. Yes the path will always change below /var/folders/* but the folder which wasn't there was "SharedPrecompiledHeaders" - which surprised me. But removing the parent folder I mentioned should work without a problem.
-
matt over 10 years@RedYeti the answer that I link to does mention removing the cache in /var/folders.
-
RedYeti over 10 years@matt well yes - sorry, true; but your summary in the answer above missed that last point which was the crucial one in my case. I must admit I hadn't followed the link to the other question.