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?

productioncoder
  • 4,225
  • 2
  • 39
  • 65
  • 1
    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. – user3353890 May 22 '16 at 21:15
  • 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. – productioncoder May 23 '16 at 09:20
  • 1
    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. – user3353890 May 23 '16 at 20:26
  • 1
    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. – productioncoder May 24 '16 at 12:21

2 Answers2

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
productioncoder
  • 4,225
  • 2
  • 39
  • 65
  • 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 ? – Alok C Aug 25 '16 at 03:56
  • 1
    Is your app in Swift or Objective-C? This: https://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)? – productioncoder Aug 25 '16 at 09:12
  • 1
    when i use import AFNetworking a error appear: No such model AFNetworking – Eduardo Oliveros Aug 25 '16 at 14:32
  • @Eduardo: Is your app in Swift or Objective-C? – productioncoder Aug 25 '16 at 16:35
  • @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 :( – Alok C Aug 26 '16 at 17:25
  • 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? – productioncoder Aug 26 '16 at 18:34
  • 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. – vaibhav Jan 19 '17 at 13:40
  • finally. after hours upon hours of searching the internet, your answer solves all my problems! – Johnny Z Aug 31 '17 at 19:05
4

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

always_beta
  • 229
  • 4
  • 10