2017-06-21 215 views
3

我在我的swift 3项目中安装了一个Objective C窗格。我在Podfile中包含“use_frameworks”,所以我不需要添加任何东西到我的桥接头。当在Swift项目中使用ObjectiveC时,cocoaPods中#import文件未找到错误

问题是,当我包括(第三方)生成试图从荚#IMPORT一个头的ObjectiveC文件 - 它失败“‘[XXXXX] .H’文件未找到”

的的ObjectiveC#import“GTLRObject.h”语句导致“GTLRObject.h文件未找到”错误。

我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 

桥接报头。我需要包括对产生的ObjectiveC类的头,所以我可以在我的SWIFT代码中使用它:

#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" 

错误是在GTLREchoObjects.h。 #进口“GTLRObject.h” = “‘GTLRObject.h’找不到文件”

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

如果我尝试和迅速文件引用GTLRObject我没有得到任何错误例如

import Foundation 
import GoogleAPIClientForREST 

class ControllerHello: NSObject { 

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

任何意见赞赏。

+0

更新用户标题搜索路径似乎解决了这个问题。见[这个答案。](https://stackoverflow.com/questions/29080026/how-to-reference-header-files-in-bridging-header-h-after-updating-cocoapods-to-0) – greentor

回答

3

既然这个答案我对别人有用。

当使用GoogleAPIClientForREST

打开TARGETS>App>Build Settings

User Header Search Paths对于添加Pods和选择recursive

enter image description here

相关问题