gpt4 book ai didi

objective-c - #import 文件在 Swift 项目中使用 ObjectiveC 时在 cocoaPods 中找不到错误

转载 作者:搜寻专家 更新时间:2023-10-31 08:24:51 24 4
gpt4 key购买 nike

我在我的 swift 3 项目中安装了一个 Objective C pod。我在 Podfile 中包含“use_frameworks”,因此我不需要在我的桥接 header 中添加任何内容。

问题是当我包含一个(第三方)生成的 ObjectiveC 文件时,该文件试图从 pod 中#import 一个 header - 它失败并显示“'[xxxxx].h' file not found”

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

我的播客文件:

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 类的 header ,以便我可以在我的 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 中。 #import "GTLRObject.h"= "'GTLRObject.h' 文件未找到":

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

如果我尝试从 swift 文件中引用 GTLRObject,我不会收到任何错误,例如

import Foundation
import GoogleAPIClientForREST

class ControllerHello: NSObject {

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

感谢任何建议。

最佳答案

因为这个答案可能对其他人有用。

使用 GoogleAPIClientForREST 时:

打开 TARGETS > App > Build Settings

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

enter image description here

关于objective-c - #import 文件在 Swift 项目中使用 ObjectiveC 时在 cocoaPods 中找不到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44680219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com