Xcode 9 - failed to emit precompiled header

71,096

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
Share:
71,096
Shubham
Author by

Shubham

Updated on February 26, 2020

Comments

  • Shubham
    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
    Harshad Madaye about 6 years
    perfect, i had disabled it to inprove build time , and then i forgot, thanks buddy
  • Gustavo Parrado
    Gustavo Parrado about 6 years
    I've put it on .h files, it works fine, that's not the problem
  • Jefferson Setiawan
    Jefferson Setiawan almost 6 years
    This happen to me too, How do you fix this things?
  • Daniel Dramond
    Daniel Dramond almost 6 years
    @Harris this was the workaround for me. Thank you.
  • Elsammak
    Elsammak almost 6 years
    The only answer worked with me..thanks man :+1:
  • Marc-Alexandre Bérubé
    Marc-Alexandre Bérubé almost 6 years
    Sorry 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
    iOS over 5 years
    Really it matters!
  • xGoPox
    xGoPox over 5 years
    Thanks! 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
    musical_coder almost 5 years
    You may also need to forward-declare classes and protocols in the .h file: developer.apple.com/documentation/swift/…
  • Wide Angle Technology
    Wide Angle Technology over 4 years
    How did you do this?
  • Ronaldo Albertini
    Ronaldo Albertini over 4 years
    I was -project and it does not work with *.xworkspace. -workspace solved :)
  • Iulian  Nikolaiev
    Iulian Nikolaiev over 2 years
    The 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
    Raphael almost 2 years
    Quite unlike the other suggestions here, this worked for me