Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#import file not found error in cocoaPods when using ObjectiveC in Swift project

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.

like image 637
Peter Todd Avatar asked Jun 21 '17 15:06

Peter Todd


1 Answers

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

like image 61
gbhall Avatar answered Nov 14 '22 09:11

gbhall