Xcode 9 - failed to emit precompiled header
Solution 1
Finally i got the solution of this issue.
In my project the Prefix Header
path is not clearly defined. Earlier the path was
$(SRCROOT)/MyPrefixHeaderFile.pch
MyPrefixHeaderFile.pch
is in another folder inside the project folder, So i update the Prefix Header
path to
$(SRCROOT)/FolderName/MyPrefixHeaderFile.pch
Solution 2
I found out that I accidentally opened the ProjectName.xcodeproj file rather than the ProjectName.xcworkspace file.
Open the xcworkspace file, project will start working again!
Solution 3
Read this if you using cocoapods in project. I just update deployment target to iOS 10 or 11 in my case after updating pods and xcode make first build success. So problem was inside podfile where I had line
platform :ios, '11.0'
and my deployment target in project was 9.0 after I change my podfile to platform to
platform :ios, '9.0'
project was fixed.
Solution 4
Also make sure your import of "ProductModuleName-Swift.h" is in your .m file, and not your .h file.
Solution 5
Maybe you created a new target, but forgot to add this to your Podfile:
target 'Pistachio-rrzcpjs' do
end
Shubham
Updated on February 26, 2020Comments
-
Shubham about 4 years
I have a project in Objective-C as well as in swift by taking
MyProjectName-Bridging-Header.h
and i also configured the Objective-C Bridging Header. Also i have added 'MyprojectName-Swift.h' in .pch file.This works fine on xcode 8.2 but when i build my project from xcode 9 i am getting the below error.
failed to emit precompiled header '/Library/Developer/Xcode/DerivedData/MyprojectName-lajanjvhqjnfjksdsndsfkads/Build/Intermediates.noindex/PrecompiledHeaders/MyprojectName-Bridging-Header-swift_44AHJm3Z96qu-clang_2BIMGQVXGEZ09.pch' for bridging header '/Documents/MyProjectLocaiton/FoneApp-Bridging-Header.h'
Please help me out from this. Thanks!
-
Harshad Madaye about 6 yearsperfect, i had disabled it to inprove build time , and then i forgot, thanks buddy
-
Gustavo Parrado about 6 yearsI've put it on .h files, it works fine, that's not the problem
-
Jefferson Setiawan almost 6 yearsThis happen to me too, How do you fix this things?
-
Daniel Dramond almost 6 years@Harris this was the workaround for me. Thank you.
-
Elsammak almost 6 yearsThe only answer worked with me..thanks man :+1:
-
Marc-Alexandre Bérubé almost 6 yearsSorry for the delay, you must make sure your header files imported in the bridging header contains all of their dependencies (even those who were implied from the Prefix header)
-
iOS over 5 yearsReally it matters!
-
xGoPox over 5 yearsThanks! I had this issue while merging branches, my podfile was set to platform :ios, '10.3' while my xcode minimum deployment target was still at 10.0, you need to change it to 10.3 in xcode THEN run pod install
-
musical_coder almost 5 yearsYou may also need to forward-declare classes and protocols in the .h file: developer.apple.com/documentation/swift/…
-
Wide Angle Technology over 4 yearsHow did you do this?
-
Ronaldo Albertini over 4 yearsI was -project and it does not work with *.xworkspace. -workspace solved :)
-
Iulian Nikolaiev over 2 yearsThe answer really helped me when I tried to run unit tests. The only thing I needed was to add something like: "target :AppTests do #some pods end" in podfile
-
Raphael almost 2 yearsQuite unlike the other suggestions here, this worked for me