Xcode version 4.6.2 (4H1003) compiler error
Asked Answered
M

9

88

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?

Mikamikado answered 16/4, 2013 at 2:23 Comment(2)
I tried doing a Product-->Clean and deleting the previously built app off of the simulator. Neither worked.Mikamikado
"Clean Build Folder" didn't solve my problem when building to a device (tried several times). I had to "Clean Build Folder", build to simulator, then build to device it was resolved.Ornithology
L
183

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

Lazar answered 16/4, 2013 at 2:30 Comment(8)
Yes, 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.Owl
If 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...Lazar
This worked for me after doing the 'Clean Build Folder' with option held down. Thanks!Daunt
This worked for me thanks...I didn't know holding the option does a different kind of clean.Mikamikado
This only works for building within Xcode. If you're building from the command line, see Rodrigo Lima's post below.Polaris
Didn't work for me - however the extra step given by @karim's did (find and delete the folder in the "Precompiled Headers Path").Fourierism
@Fourierism the answer that I link to does mention removing the cache in /var/folders.Lazar
@Lazar 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.Fourierism
S
20

Go to your project's Build Settings, find a setting named Precompiled Headers Cache Path, then delete that folder

Subtropics answered 16/4, 2013 at 4:31 Comment(1)
Only this action helped me with mentioned problem. Thanks!Crake
C
13

Do a cleanup using command+shift+k and run existing project again.

enter image description here

Ceroplastics answered 16/4, 2013 at 10:31 Comment(0)
C
9

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

Coughlin answered 17/4, 2013 at 5:14 Comment(1)
Yes 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, @Subtropics does (clear Precompiled Headers Cache Path).Crackerjack
P
9

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.

Partlet answered 24/4, 2013 at 13:56 Comment(3)
This 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 SharedPrecompiledDaisydaitzman
I 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.Polaris
If 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.Sericeous
W
4

I had to manually delete ~/Library/Developer/Xcode/DerivedData/ Clean didn't work for me.

Warmhearted answered 19/4, 2013 at 11:11 Comment(0)
N
4

Specially if you build from command line or you have a build script, cleaning xcode target is not enough. You have to delete this folder.

The 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.

Target -> build settings => "Build locations" -> Precompiled headers cached path

Run Terminal and go to this folder and delete (use command),

#rm -fr SharedPrecompiledHeaders

enter image description here

Neille answered 26/4, 2013 at 7:13 Comment(3)
Great 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.Fourierism
The 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.Neille
Sorry - 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.Fourierism
L
0

use "command+shift+k" to clean your project, then you'll be fine.

Luker answered 26/5, 2013 at 22:12 Comment(0)
F
0

Clean Your project and run

Product- > Clean Then, Run.

Fabiano answered 10/12, 2013 at 4:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.