6

I install an Objective C pod to my swift 3 project. I include “use_frameworks” in the Podfile so I don’t need to add anything to my bridging header.

The problem is when I include a (third party) generated ObjectiveC file that attempts to #import a header from the pod - it fails with “‘[xxxxx].h’ file not found”

The ObjectiveC #import "GTLRObject.h" statement causes "GTLRObject.h file not found" error.

My Podfile:

target 'myHelloWorld' do
 # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
 use_frameworks!
 pod 'GoogleAPIClientForREST'
end

Bridging header. I need to include the header for the generated ObjectiveC class so I can use it in my swift code :

#import "GTLREcho.h"

GTLREcho.h:

// NOTE: This file was generated by the ServiceGenerator.

// ----------------------------------------------------------------------------
// API:
//   echo/v1
// Description:
//   This is an API

#import "GTLREchoObjects.h"
#import "GTLREchoQuery.h"
#import "GTLREchoService.h"

Error is in GTLREchoObjects.h. #import "GTLRObject.h" = "'GTLRObject.h' file not found":

#if GTLR_BUILT_AS_FRAMEWORK
   #import "GTLR/GTLRObject.h"
#else
   #import "GTLRObject.h"
#endif

If I try and reference GTLRObject from a swift file I don't get any error e.g.

import Foundation
import GoogleAPIClientForREST

class ControllerHello: NSObject {

func sayHello(strTest: String){
    let gtlObject = GTLRObject
    }
}

Any advice appreciated.

Peter Todd
  • 8,561
  • 3
  • 32
  • 38
  • Updating User Header Search Paths seemed to resolve this. See [this answer.](https://stackoverflow.com/questions/29080026/how-to-reference-header-files-in-bridging-header-h-after-updating-cocoapods-to-0) – Peter Todd Jun 21 '17 at 16:12

1 Answers1

6

Since this answer might be useful for others.

When using GoogleAPIClientForREST:

Open TARGETS > App > Build Settings

For User Header Search Paths add Pods and select recursive.

enter image description here

Aamir
  • 16,329
  • 10
  • 59
  • 65
gbhall
  • 13,139
  • 9
  • 37
  • 42