Failed to emit precompiled header for bridging header

后端 未结 20 1407
傲寒
傲寒 2020-11-30 04:35

I downloaded a project from GitHub, then pod the following files, some of which are written by OBJ-C and I used a bridge header.

pod ‘SnapKit’
pod ‘MJRefresh         


        
相关标签:
20条回答
  • 2020-11-30 05:02

    For me, this problem occurred when I added new build configuration and scheme to the existing project.

    The solution was to run pod install on newly created scheme. After that, project was built successfully.

    0 讨论(0)
  • 2020-11-30 05:06

    Note this can also happen if your bridging header imports Objective-C code that itself imports your app's Swift module via myproject-Swift.h. The solution is to use forward declarations for your Swift types and import the project Swift module in the .m file.

    @class MySwiftClass or...

    typedef NS_ENUM(NSInteger, MySwiftEnumType)

    MySwiftEnumType is the lowest level name even for classes. So Swift enum MyClass.MySwiftEnumType becomes just MySwiftEnumType

    0 讨论(0)
  • 2020-11-30 05:07

    In my case;

    Under Target/Build Settings/

    Product_Name section was different than $(TARGET_NAME)

    When I changed it $(TARGET_NAME), it was resolved.

    0 讨论(0)
  • 2020-11-30 05:09

    There are so many reasons and things can do, like:

    • Restart Xcode, Clean, Build
    • Remove Pods directory and pod install
    • Check the missing file is added to your pod file
    • Check the missing file is added to you bridging header
    • Change the header settings like here iOS - Build fails with CocoaPods cannot find header files

    The only one works for me is the accepted answer in Xcode 9 - failed to emit precompiled header.

    platform :ios, '11.0' in podfile should match the target in the project

    0 讨论(0)
  • 2020-11-30 05:09

    I had this issue just when compiling for a simulator not for a hardware device. There were two compile error like:

    • error: failed to emit precompiled header 'Bridging-Header-97bd5f.pch' for bridging header 'Bridging-Header.h'
    • Could not find ActionSheetPicker_3_0/ActionSheetPicker.h in Bridging Header (but it was declared there)

    After hours of research and try and errors it turned out, that there was no valid architecture set in the project to compile for simulators.

    At Project -> Build Settings -> User-Defined -> VALID_ARCHS add the architecture x86_64 to enable compilation for simulators.

    0 讨论(0)
  • 2020-11-30 05:14

    I also got exact same issue (Xcode9 beta 6) after I added cocoa pods for Encrypted Core Data.
    This is my PodFile:

    # Uncomment the next line to define a global platform for your project
    platform :ios, '9.0'
    pod 'EncryptedCoreData', :git => 'https://github.com/project-imas/encrypted-core-data.git'
    
    target 'Root' do
      # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
      use_frameworks!
    
      # Pods for Root
    
      target 'RootTests' do
        inherit! :search_paths
        # Pods for testing
      end
    
      target 'RootUITests' do
        inherit! :search_paths
        # Pods for testing
      end
    
    end
    

    Solution:
    1 I added $(inherited) non-recursive to Search Path -> Header Search Paths
    2 Then added ${PODS_ROOT} recursive to Search Path -> User Header Search Paths
    Both the above in my projects' target build settings.

    Please have a look at these SO answers:
    1 Inherit Header Search Paths
    2 Inherit User Search Paths

    0 讨论(0)
提交回复
热议问题