5

I have no idea why this is happening. I've installed AFNetworking in my project via a Podfile. Here's the current entry:

pod 'AFNetworking', '~> 1.2'

However when I call:

#import "AFHTTPClient.h"

at the top of one of my files, it says "'AFHTTPClient.h' file not found". If I open up the Pods directory, AFNetworking is in there along with AFHTTPClient.h. I have no idea what's going on. Any ideas?

Nick ONeill
  • 7,341
  • 10
  • 47
  • 61

2 Answers2

5

It can be because 'HEADER_SEARCH_PATHS doesn't have proper path to search in your added Pod(AFNetworking).

> Open xcworkspace (as after adding podfile/s it is recommended to open xcworkspace instead xcodeproj) and do the following:

  • In file Pods.xcconfig check HEADER_SEARCH_PATHS (example: ${PODS_HEADERS_SEARCH_PATHS} ) and copy it.
  • Now in 'Build Settings' of your 'app Target' add copied HEADER_SEARCH_PATHS to setting 'Header search path'

Alternative approach (Referred from iOS - Build fails with CocoaPods cannot find header files ):

  • In app target , to "User Header Search Paths" entry add following (including quotes)

    "${PODS_ROOT}/BuildHeaders"
    
  • checking 'recursive'



I hope this will solve this File not found issue.

Community
  • 1
  • 1
Alphonse R. Dsouza
  • 2,011
  • 1
  • 14
  • 11
  • 1
    If assuring the correct header path will not help, in addition to the aforementioned steps delete the xcuserdata folders in your xcodeproj and xcworkspace folders. If you cannot open them in Finder, right click on the xcodeproj resp. xcworkspace folders and choose "Show Package Contents". This will open these folders. Close XCode, delete the xcuserdata folders and restart XCode. This will rid you off these pesky "File not found" error messages. – MatthiasC Aug 19 '13 at 09:58
1

do you open xcworkspace? or xcodeproj? if you use CocoaPods, you always should work only with xcworkspace.

can you find other pods? try to clean the project and try again.

check whether you've done everything from this list: Creating a project that uses CocoaPods

someone had the same problem recently - can't search header path?. try to check your header search path.

Dmitry Khryukin
  • 6,408
  • 7
  • 36
  • 58
  • @NickONeill can you find other pods? try to clean the project and try again. – Dmitry Khryukin May 05 '13 at 23:00
  • I deleted all my other pods ... tried cleaning already as well. – Nick ONeill May 05 '13 at 23:02
  • @NickONeill have you done this: "Check if the pod header files are correctly symlinked in Pods/Headers and you are not overriding the HEADER_SEARCH_PATHS (see #1)." ? – Dmitry Khryukin May 05 '13 at 23:08
  • This issue appears to have provided part of the solution: http://stackoverflow.com/questions/15689844/cocapods-importing-afnetworking-but-not-ohattributedlabel – Nick ONeill May 05 '13 at 23:19
  • Pods.xcconfig was not copied into my main project. – Nick ONeill May 05 '13 at 23:26
  • @NickONeill good. point 2 from the second FAQ here - https://github.com/CocoaPods/CocoaPods/wiki/Creating-a-project-that-uses-CocoaPods usually something doesn't work because of such small things of misprints. – Dmitry Khryukin May 05 '13 at 23:35