iOS – Build fails with CocoaPods cannot find header files

| | August 5, 2015

I have an iOS project using CocoaPods. Everything was working smoothly until another developer started to work on the same project. He made some changes (only to code as far as I know) and made a new branch in the repo. I have checked out his branch and tried to build it, but I am getting an error: ASLogger/ASLogger.h file not found.

Even if I delete the whole project and make a fresh copy and use ‘pods install .’ the build failure is still there. Do you have any idea where the problem can be? If you need some more infos, just ask.

16 Responses to “iOS – Build fails with CocoaPods cannot find header files”

  1. Nazar Stadnytskyi on November 30, -0001 @ 12:00 AM

    Problem is actually in source control.
    Just switch to your branch, previously commited all changes.

  2. 1.check User Header Search Paths(build settings)

    • “${PODS_ROOT}/” recursive

    2.check import style,
    if your’s profile have set
    use_frameworks!

    You should import .h like this #import "MBProgressHUD.h"
    else
    You should import .h like this #import <MBProgressHUD.h>

    3.That must be work. trust me

  3. The wiki gives an advice on how to solve this problem:

    If Xcode can’t find the headers of the dependencies:

    Check if the pod header files are correctly symlinked in Pods/Headers
    and you are not overriding the HEADER_SEARCH_PATHS (see #1). If Xcode
    still can’t find them, as a last resort you can prepend your imports,
    e.g. #import “Pods/SSZipArchive.h”.

  4. If you had the building errors after a “pod install” or a “pod update“, it may be that one of your pods have been built with XCode 6.3 while you are still using a previous version.

    In my case I had to update my OSX from mavericks to Yosemite to have Xcode 6.3 and solve the problem

  5. None of the answers helped me (I had my pods linked with all targets, build configurations setup properly, correclty set search paths “$(inherited)”, etc…).

    Problem disappeared by itself after I updated cocoapods to the newest, debug version using standard install / update command:

       gem install cocoapods --pre
    

    or:

       sudo gem install cocoapods --pre
    

    (if sudo was used during installation).

    It must have been cocoapods bug.

  6. I had to download the zip from git hub and drag the missing files into the Finder at corresponding paths in Pod/…

  7. Here’s what worked for me:

    Go to the Target > “Build Settings” tab and find the “User Header Search Paths” setting.

    Set this to “$(BUILT_PRODUCTS_DIR)” and check the “Recursive” check box.

    Now the built target will search the workspace’s shared build directory to locate the linkable header files.

    ====

    UPDATE

    I had a similar (although slightly different) problem recently. It turned out Xcode couldn’t find the Pods because I had opened up the .xcodeproj file rather than the .xcworkspace file. Might help others in the future.

  8. for me the problem was in Other Linker flags value. For some reason I had no quotes in flags like -l"xml2" -l"Pods-MBProgressHUD".

  9. Update

    Make sure your Podfile includes link_with on targets missing a config file. Cocoapods only sets the first target by default otherwise. e.g.

    platform :osx, '10.7'
    pod 'JSONKit',       '~> 1.4'
    
    link_with 'Pomo', 'Pomo Dev', 'Pomo Tests'
    

    —— End Update


    Note: Please do note that you have to look into Project->Info->Configurations for steps below.


    I had similar symptoms and found that the pods.xcconfig file was not being included in the specific target I was trying to build. Some of the other suggested solutions worked for me, but this one seemed to address part of the underlying issue.

    Pods.xcconfig not working

    The simple solution was to change set the configuration file for the targets that didn’t have one set.

    Pods.xcconfig working

  10. This was the answer for me, I updated cocoapods and I think that made the PODS_HEADERS_SEARCH_PATHS go away. My solution was similar to this but I used “$(PODS_ROOT)/Headers” – Andrew Aitken

    Thank you so much for this answer. I had a hard time looking for ways to fix my problem. Thank you very much.

  11. I was on the GM seed of Xcode 5.0 and I couldn’t get any of these answers to work. I tried every single answer on SO on multiple different questions about header imports w/ cocoapods.

    FINALLY I found a solution that worked for me: I upgraded to Xcode 5.0 via the Mac AppStore (installed on top of the GM seed) and now the header imports are working as expected.

    I also still had a beta version of Xcode 5 on my system and I deleted that as well. Maybe it was a combination of the two things, but hopefully this helps someone else.

  12. Did you try importing Cocoapods style?

    #import <ASLogger.h>
    

    The info on the site is not really clear, I submitted a pull request:

    https://github.com/CocoaPods/cocoapods.org/pull/34

    Update: They pulled my request :)

  13. i found ${PODS_HEADERS_SEARCH_PATHS} is missing and it is not defined in my develop git branch, So i added "$(SRCROOT)/Pods/Headers/" for Header Search Paths with recursive

    That is ok for me

  14. Both other answers didn’t help here. I found 2 other problems that might fix it:

    EDIT
    You can check a symlink this way: create a textfile named ‘check’ without an extension. copy these lines into it:

    file=/Users/youUserName/XcodeProjectName/Pods/BuildHeaders/SVProgressHUD/SVProgressHUD.h
    if [[ ! -e $file &&  -L $file ]]; then
      echo "$file symlink is  broken!"
    else
      echo "symlink works"
    fi
    

    Then go to the terminal, change to the folder where your check file is located and type

    bash check
    
  15. Header files, you’ll be the death of me…

    Finally got it to work by adding (including quotes)

    "${PODS_ROOT}/BuildHeaders"
    

    to the User Header Search Paths entry, and checking ‘recursive’.

  16. Update

    I’ve updated this since my original answer, that got the downvote, so I hope this helps. And if it does, hopefully it will get my vote back.

    If the headers aren’t being imported, you probably have a conflict in the HEADER_SEARCH_PATHS. Try and add $(inherited) to the header search paths in your Build Settings to make sure that it pulls in any search paths included in the .xcconfig file from your CocoaPods.

    This should help with any conflicts and get your source imported correctly.

Leave a Reply