Cocoapods 1.0: Header files not found
Asked Answered
P

2

29

I just tried to update from cocoapods 0.39.x to Cocoapods 1.0. Running

pod install

from the terminal causes no warnings. Everything seems normal. However, when I try to build my project it outputs:

AFNetworking/AFNetworking.h file not found

My pod file looks like this (there are a few more dependencies but I only listed a part of it):

platform :ios, '8.0'
use_frameworks!
source 'https://github.com/CocoaPods/Specs.git'

target 'MyApp' do
    pod 'AFNetworking', '~> 2.6'
    pod 'BEMCheckBox'
    pod 'ActionSheetPicker-3.0', '~> 2.0.5'
    pod 'SCLAlertView'
    pod 'DZNEmptyDataSet'
    pod 'SSZipArchive'
end


target 'MyAppTests' do

end

Since some projects are written in Objective-C, i created a bridging header:

#import <AFNetworking/AFNetworking.h>
#import <ActionSheetPicker_3_0/ActionSheetPicker.h>
#import <SSZipArchive/SSZipArchive.h>
#import <DZNEmptyDataSet/UIScrollView+EmptyDataSet.h>

I explicitly included $(inherited) in the Header Search Paths, the User Header Search paths, and the Framework Search paths but the error does not go away. Does someone have an idea on how to fix this?

Perfectly answered 22/5, 2016 at 17:32 Comment(4)
A few suggestions to begin with...unrelated to your question, but if you're coding in Swift try using Alamofire instead of AFNetworking. They both have the same creator, but Alamofire is basically the Swift version of AFNetworking. It makes things a little easier. Second, make sure you're opening your project as a xcworkspace instead of an xcodeproj. Cocoapods will only work in xcworkspace. If that's not the issue I can try to help further.Chipman
Thanks for your suggestions. Yes, I totally agree. But I have to use AFNetworking because another dependency is written in Objective C and uses AFNetworking and not Alamofire. I've already been working in xcworkspace, in fact it was a use_frameworks issue.Perfectly
Gotcha. Have you tried to just run your app? I've had the issue before where I get the "file not found" error, but I clean the build and run the app and it clears up all of the issues. It's almost like the error is an error.Chipman
Yes, I've tried that, but it didn't compile, I still had the same error. I fixed it by removing some imports from my bridging header as described in my answer.Perfectly
P
36

The error message is quite misleading. At first I thought I have some problems with my header search paths, so I basically tried everything I found on stackoverflow.

If you use use_frameworks! in your Podfile, you don't have to include every Objective-C pod in your bridging header. You only have to do this, if the pod is distributed as a static library, not as a framework.

I did the following

  1. Press Cmd + option + shift + k to clean your build folder
  2. Run pod install
  3. Delete the lines in your bridging header where it tells you that the header files are not found and use a simple import statement whenever you want to use that module in one specific Swift file, e.g. import AFNetworking
Perfectly answered 23/5, 2016 at 9:18 Comment(8)
What if I am not using 'use_frameworks' ? My error is not going away, neither its finding them as module. I tried deintegrate and clean. Its the same code base that I build and submitted to appstore. Any suggestions ?Collaborate
Is your app in Swift or Objective-C? This: guides.codepath.com/ios/CocoaPods might be useful for you. If your app is in Swift, I would always go with use_frameworks. use_frameworks enables you to add Swift pods. Unfortunately not all Objective-C pods can be distributed as a framework. If your run into issues you probably need to import the headers of the pod in a bridging header (only if the Objective-C pod is NOT distributed as a framework.). If the system does not find the headers, you have to start modifying the Header Search paths (have you tried the 'recursive' options)?Perfectly
when i use import AFNetworking a error appear: No such model AFNetworkingVoiced
@Eduardo: Is your app in Swift or Objective-C?Perfectly
@slashburn : My project is Objective C. I am implememnting as you said. problem is I have mix of pods which are distributed as pod and not :(Collaborate
On which kind of dependencies do you get the error "module not found". On dependencies you included using CocoaPods or on dependencies you included manually?Perfectly
your solution is workaround but still cant understand the reason of not finding Bridging-Header file and ultimately its not the exact error, plus one for you and it is use_frameworks! with not sign not only use_frameworks kindly update.Eternalize
finally. after hours upon hours of searching the internet, your answer solves all my problems!Rags
W
4

I tried remove ~/Library/Developer/Xcode/DerivedData/* and rebuild the project, and it worked for me.

Waxbill answered 21/11, 2016 at 3:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.