207

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.

Filip Majernik
  • 7,700
  • 13
  • 45
  • 53

30 Answers30

208

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

rohan-patel
  • 5,772
  • 5
  • 45
  • 68
waggles
  • 2,804
  • 1
  • 15
  • 16
  • 4
    For me, ''pods install'' only set this on the first target. Doing as suggested in this answer solved my problem. – Troy Aug 24 '13 at 20:50
  • 1
    Finally a solution: Pods was added ONLY to first target, not to various test release targets (alpha, beta, release candidate)! Great many thanx! – JOM Oct 16 '13 at 07:04
  • Using `link_with` to specify my other target worked for me. Many thanks. I just spent several hours on this. – Dylan Hand Oct 17 '14 at 00:59
  • this worked for me! i cloned an existing project, and then updated pods. so i am guessing updating pods flipped some settings, or the previos dev was using xcode 5 or something (i'm on xcode 6), thanks!!! – greenhouse Dec 01 '14 at 03:35
  • Great work! On Xcode 6 I can't find Project->Info, but by changing the Podfile and then doing 'pod update' I finally got my project working. – ljk321 Dec 21 '14 at 05:04
  • Set configuration for Test target worked for me. Even if I'm not building (or even using) Test target at all! – Kenneth Jiang Jan 22 '15 at 19:17
  • This worked for me with a slight modification to also set Pods.* on the actual "project" (top-level Pomo in this case). – joacar Jun 15 '15 at 11:16
  • @Troy: where I find that Configurations in latest version of `XCode Version 7.0 (7A220)` ? – el.severo Sep 21 '15 at 13:50
  • @joacar Same place as pictured, but be sure to click "Info" at the top of the window (vs. "Build Settings") – Troy Sep 21 '15 at 16:56
  • link_with is no longer supported, so what's the best way to do this now (without having to muck about in XCode settings)? – shmim Jan 20 '16 at 14:52
  • Yes, make sure you're looking at the project settings, not the target settings, but otherwise it still seems to be there, and this solved my header search failure. – Geoffrey Wiseman Apr 11 '16 at 20:10
  • If you came across this problem after migrating to `use_frameworks!` see my answer below. – Scott Fister May 18 '16 at 03:36
  • 4
    `link_with` is unsupported in Cocoapods 1.0 or higher. – Nat May 29 '16 at 13:45
  • I seeing the same issue, none of pod thing is applied to second target. I think its cocoapods version 1 problem too. But I am not able to find this configuration screens in xcode 7.3. Any one can help please. wasted whole 2 days and million branches. plus non of the pod are visible too :( – Alok C Aug 25 '16 at 04:49
  • I had been switching between two targets and even though I was building for a target that had the correct configurations. The target that had no configurations (that I wasn't even building) was somehow effecting it. So; make sure your configurations are correct for all targets!!!!! – Johann Burgess Nov 13 '16 at 07:22
  • 1
    @Vive is correct that "link_with" is unsupported. We should use "target" instead. So in this sample it should be changed like that >>> target 'Pomo', 'Pomo Dev', 'Pomo Tests' – Richter May 04 '19 at 11:00
98

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.

starball
  • 20,030
  • 7
  • 43
  • 238
Bill Burgess
  • 14,054
  • 6
  • 49
  • 86
  • 2
    I had faced issue:Pod files were not getting detected in app and 'svn obstructed folder issue' which occurs when you have deleted or moved the .svn subdirectories: Solution: by following steps: 1.Uninstall CocoaPods from app so only . xcodeproj file exists (referred : http://stackoverflow.com/questions/16427421/how-to-remove-cocoapods-from-a-project) 2.Installed podfiles again (referred: http://www.raywenderlich.com/12139/introduction-to-cocoapods) 3. $(inherited) flag added in target 'HEADER_SEARCH_PATHS' and 'OTHER_LDFLAGS' of the app. – Alphonse R. Dsouza Apr 16 '14 at 12:09
  • 1
    You may also need to add $(inherited) to your FRAMEWORK_SEARCH_PATHS setting. – George May 25 '14 at 16:55
  • 1
    @AlphonseR.Dsouza your solution worked for me - added $(inherited) to OTHER_LDFLAGS thanks a million! – Nika Kasradze Dec 06 '15 at 11:32
  • 4
    $(inherited) should be added in project settings or target settings? – skypirate Dec 11 '15 at 02:39
  • I had similar problem, I had no past experience with pods. In the Podfile also, I didnt mention 2 targets. Yes I was having 2 targets. Once I mentioned the 2nd target and updated the Pod file, teh terminal stated some warning similar to your suggestion to add $inherrited. I did and it worked perfectly. – Jasmeet Jun 15 '16 at 02:19
  • @Bill Burgess where do I need to add that inherited word? in the Build Settings of my main project or in the PODs project? – VAAA Apr 26 '17 at 19:47
  • Just search your build settings for the listed key, then add it there. – Bill Burgess Apr 26 '17 at 22:59
  • TFW you solve your own problem... again after 9 years. Thanks me! – Bill Burgess Aug 20 '21 at 20:58
85

1.Check

build settings -> Search Path -> User Header Search Paths ->

  • "${PODS_ROOT}/" recursive

enter image description here

enter image description here

enter image description here enter image description here

2.Check import style(KEY POINT), if your's podfile have set

use_frameworks!

In yours File-Bridging-Header.h,the formatter should like this

#import "MBProgressHUD.h"

else should be below

#import <MBProgressHUD.h>

3.That must be work! trust me

Albert.Qing
  • 4,220
  • 4
  • 37
  • 49
  • 1
    Most errors disappear. However what shall I do when a dependency has an import statement like: #import . Then the compiler tells me to instead write #import EARestrictedScrollView.h. But I can't modify my pod. – productioncoder May 22 '16 at 18:54
64

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

averydev
  • 5,717
  • 2
  • 35
  • 35
  • 6
    Note that the quotes are very important here. Without them, I couldn't get it to work. – DiscDev Sep 29 '13 at 00:30
  • 5
    +1 I already had `$(inherited)` (wasn't working) but adding this worked for me. – iwasrobbed Dec 05 '13 at 17:13
  • Did not get what you are trying to say. :/ Caould you please elaborate? – rohan-patel Jun 25 '14 at 20:20
  • Another handy trick is to blow away the workspace and pods directory and pod install fresh. This is generally a more complete solution. – averydev Sep 10 '14 at 01:47
  • 1
    This finally helped AppCode to correctly find all header file imports. Without this, it worked in xCode, but not in AppCode. Thanks! – sarsonj Jan 06 '16 at 12:34
  • @averydev Hi i have same problem but dont know where do I have to add ${PODS_ROOT}/BuildHeaders. Do you have any screenshot please. Appreciate it – VAAA Apr 26 '17 at 15:44
  • @averydev there appears to columns with my project name can you help that did not work for me ? – Hamouda Arfaoui Apr 08 '20 at 09:36
54

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

Aamir
  • 16,329
  • 10
  • 59
  • 65
mactive
  • 1,560
  • 11
  • 7
  • 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 Jul 25 '13 at 05:23
  • The other answers did not work for me, but this one did. I'll note that I didn't include the ", so my header search path looks like this ```$(SRCROOT)/Pods/Headers``` – Blakedallen May 20 '15 at 03:41
  • @Hlung hi, where do I have to add $(SRCROOT)/Pods/Headers/ ? Appreciate it – VAAA Apr 26 '17 at 15:42
  • 1
    @VAAA Target > Build Settings > Header search path – Hlung Apr 27 '17 at 16:45
  • i think this is the right answer what should be accepted, what do you think @Filip Majernik – Ratul Sharker Apr 11 '18 at 16:39
36

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
Jeromy French
  • 11,812
  • 19
  • 76
  • 129
brainray
  • 12,512
  • 11
  • 67
  • 116
  • Thank you very much! The first entry solved it for me. Pods was set for the first target in our project only. This compiled fine, but the other target didn't. So I added the Pods configuration to it as well and now the issue is gone. – mwidmann Jun 07 '13 at 11:22
  • I dont see 'Pods' in the Configurations .. does this mean my symlink is broken? – Adamski Oct 21 '14 at 23:00
34

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.

Snowcrash
  • 80,579
  • 89
  • 266
  • 376
19

If none of the above worked for you and you are finding this error because you just switched to use_frameworks! in your Podfile, read on:

I tried all the solutions above and a lot more before learning that it isn't about search header paths at all in my particular case; it's that when you switch to use_frameworks! in your Podfile you no longer need to include frameworks in your bridging header, and in fact Xcode will throw the very unhelpful "unable to find header" error.

What you need to do is remove all imports from your bridging header file, and instead use the Swift import Module in your individual Swift files as needed, just like you would for Swift frameworks.

AND if you are using any of the framework headers in your Obj-C classes (in my case we have a convenience class that used the FBSDK) you need to change it from a local to global import (this means change #import "Module.h" to #import <Module/Module.h>, which should autocomplete for you when you begin to type the framework name. In my case it was <AFNetworking/AFHTTPRequestOperationManager.h>).

Edit: I've since learned that doing an @import Module uses the umbrella file which is even safer.

Scott Fister
  • 1,213
  • 12
  • 24
18

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 :)

Tieme
  • 62,602
  • 20
  • 102
  • 156
  • Instead of using double quote style, #import "ASLogger.h" i tried this, #import And it worked for me :) – Baig Jun 05 '13 at 11:02
  • I've tried this before and it has worked for me, but sometimes a different problems occurs when it doesn't work. You can also use format in at least some situations. – funroll Mar 27 '14 at 23:04
  • Yes this worked for me too! No amount of cleaning and deleting the derived data resolved it, but this worked. – PostCodeism Nov 20 '15 at 23:31
11

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

tilo
  • 14,009
  • 6
  • 68
  • 85
  • 16
    Could someone elaborate on exactly how to "Check if the pod header files are correctly symlinked in Pods/Headers" please? – Dave Collins Oct 16 '12 at 20:05
  • please see my answer above for how to check a symlink – brainray Dec 27 '12 at 17:35
  • Please also see brainray's answer about Configurations before you mangle your import statements. – Rog Feb 11 '13 at 12:06
  • yes, some pods are linking to an invalid directory, like `$(PROJECT_DIR)/Pods/Headers/Public/xxx/ios/xxx.h`, there is an extra of `ios` folder... – Dong Ma Oct 28 '15 at 10:38
9

I was the only developer in the team experiencing this same issue, it worked perfectly for everybody so I realized it had to be my environment. I tried a git clone of the same project in another directory and it compiled perfectly, then I realized it had to be Xcode caching stuff for my project path somewhere, that "somewhere" is the DerivedData folder, just remove it and do a clean build of your project, it worked for me.

You can get the path and even open the folder in finder by going to:

Xcode -> Preferences -> Locations -> **DerivedData

bithavoc
  • 1,539
  • 15
  • 20
  • 1
    In my case problem appeared after updating pods, so I thought in cocoapods should search the problem. I've tried all solutions here with no luck and finally just cleared DerivedData - and it helped! thank you – Varrry Oct 31 '16 at 16:40
4

I will update the below things in my Build settings and I did not get any errors. To check these are the things while updating your cocoapods.

Build Settings

Enable Bit code - YES(if you are using bitcode)

Macro preprocessor - $(inherited)

Other linker flag - objc, -lc++, $(inherited)

Build architecture only

Debug - Yes

Relese - No

Search Path

Framework search path - $(inherited) $(PROJECT_DIR)

Library search path - $(inherited)

Header search path - $(inherited)

Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
Surezz
  • 561
  • 4
  • 12
4

For me, what fixed it was the iOS deployment target for my Pods project was lower than my project itself. Once I made it the same as my project it was able to find the header file.

Josh
  • 41
  • 2
  • bro ! you deserve 1000 upvotes . i was stuck with this for 4 hours and your solution helped me out . thanks alot bro thanks alot ! – warzone_fz Jun 03 '20 at 00:44
2

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

Omaty
  • 425
  • 5
  • 14
  • Hi @omaty, is this the only solution? I'm currently running on Mavericks with Xcode 6.2 – goelv Apr 23 '15 at 04:20
  • 1
    Hello @goelv in my case it was the only solution I found. I was like you under Mavericks and Xcode 6.2. – Omaty Apr 23 '15 at 11:42
  • I think even I have same issue. My teammate has Xcode 6.3 in Yosemite and it works fine for him, whereas I am struggling to get rid of the header not found issue in Mavericks in Xcode 6.2. – Sagar S. Kadookkunnan Apr 27 '15 at 08:12
  • 1
    Follow up: I also upgraded the machine to Yosemite and Xcode 6.3.1, I am able to build without any issues now. – Sagar S. Kadookkunnan Apr 28 '15 at 04:20
1

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

beryllium
  • 29,669
  • 15
  • 106
  • 125
  • I was having problems with Localytics' Cocoapod. Under `Other Linker Flags` I found two entries: `-|Localytics` and `|-PodsLocalytics`. I removed those and then was able to compile. – Chris Jan 26 '16 at 18:22
1

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

neelamc23
  • 74
  • 4
1

What worked for me was selecting the Pods project, finding and selecting the target framework with the missing header in the Pod project's target directory and setting "Build Active Architecture Only" to "No" under "Architectures" in the target's build settings.

Aaron
  • 6,466
  • 7
  • 37
  • 75
1

I have got the same problem, but the above solutions can't work. I have fixed it by doing this:

  1. Remove the whole project
  2. Run git clone the project and run the bundle exec pod install
  3. cd the peoject and run remote add upstream your-remote-rep-add
  4. git fetch upstream
  5. git checkout master
  6. git merge upstream/master

And then it works.

Azure Yu
  • 397
  • 2
  • 5
0

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.

DiscDev
  • 38,652
  • 20
  • 117
  • 133
0

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.

user1494912
  • 350
  • 3
  • 6
0

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.

Lukasz
  • 19,816
  • 17
  • 83
  • 139
0

One simple workaround is: 1. Delete Pods folder and Podfile.lock file. But don't delete Podfile 2. Run following command in your project root folder:

pod install
farhad rubel
  • 2,334
  • 2
  • 22
  • 29
0

Here's another reason: All the header paths seemed fine, but we still had an error in the precompiled (.pch) file trying to read a pod header

(i.e. #import <CocoaLumberjack/CocoaLumberjack.h>).

Looking at the raw build output, I finally noticed that the error was breaking our Watch OS Extension Target, not the main target we were building, because we were also importing the .pch precompiled header file into the Watch OS targets, and it was failing there. Make sure your accompanying Watch OS target settings don't try to import the .pch file (especially if you set that import from the master target setting, like I did!)

Owen Hartnett
  • 5,925
  • 2
  • 19
  • 35
0

I've found that including the library as a pod install directly helps dynamic libraries. For example, for Firebase:

pod 'RNFirebase', :path => 'path/to/node_modules/react-native-firebase/ios'

Or for ASLogger:

pod 'ASLogger', :path => 'path/to/node_modules/aslogger/ios' // path to header files

Changing or hardcoding HEADER_SEARCH_PATHS did not help me. If the error ever recurs, it's not necessary to rm -rf node_modules nor delete the pod file etc, I found it useful to clear the cache.

For react-native, I run

    rm -rf $TMPDIR/react-native-packager-cache-*
    rm -rf $TMPDIR/metro-bundler-cache-*
    rm -rf $TMPDIR/metro-* 
    rm -rf $TMPDIR/react-* 
    rm -rf $TMPDIR/haste-*
    rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
    npm start -- --reset-cache

For Xcode I remove folders in ~/Library/Developer/Xcode/DerivedData

ehacinom
  • 8,070
  • 7
  • 43
  • 65
0

I think an ultimate solution is to go to Build settings -> Search Path -> User Header Search Paths, find your library path and go through it in a Finder. Make sure that all path exists including your import path.

For me my path was shorter than in a tutorial. In tutorial it was something like #import <SDK/path/to/sdk/File.h>, but turns out it is just #import <SDK/File.h>

Simon Moshenko
  • 2,028
  • 1
  • 15
  • 36
0

If you're on Xcode 12 or above, make sure your Pods are being compiled for the correct architecture (Intel vs. ARM). Check to see if you have a VALID_ARCHS or EXCLUDED_ARCHS setting anywhere.

I had config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64' in my Podfile, and that prevented the compiler from finding the Pod header files.

Josh
  • 2,790
  • 26
  • 30
0

I ran into similar issue while running an Objective-C code on my M1 Macbook Pro. It was running completely fine on Intel based Macs.

This is how I solved my issue:

Copy your pods from Podfile and then run following commands using Terminal.

sudo gem install cocoapods-deintegrate cocoapods-clean

pod deintegrate

pod cache clean --all

rm Podfile

rm Podfile.lock

pod init

Paste your copied pods into the Podfile and run following command on Terminal.

pod install

This worked for me.

-2

Have a try to comment this line for your target

#  use_frameworks!

Or you can refer to my another answer added unit testing target to xcode - failed to import bridging header won't go away

Community
  • 1
  • 1
Victor Choy
  • 4,006
  • 28
  • 35
-2

I solved this issues for Xcode 8.2.1 by drag and drop framework that i want to use.

-2

I have other worked solution here,

  1. Quit Xcode
  2. Open Xcode and clean project
  3. Build Pods project first
  4. Build Project
Pramod More
  • 1,220
  • 2
  • 22
  • 51