ios 将 CocoaPods 更新到 0.36.x 及更高版本后如何引用 Bridging-Header.h 中的头文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29080026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 05:13:26  来源:igfitidea点击:

How to reference header files in Bridging-Header.h after updating CocoaPods to 0.36.x and above?

iosswiftcocoapodsios-frameworks

提问by nmdias

After updating to CocoaPods 0.36.x, I am unable to add imports into my Bridging-Header.h file. I get the "DBSphereView.h file not found".

更新到 CocoaPods 0.36.x 后,我无法将导入添加到 Bridging-Header.h 文件中。我得到“未找到 DBSphereView.h 文件”。

The file is indeed present in:

该文件确实存在于:

"Pods/DBSphereTagCloud/DBSphereView.h"
"Headers/public/DBSphereTagCloud/DBSphereView.h"
"Headers/private/DBSphereTagCloud/DBSphereView.h"

My bridge file:

我的桥文件:

#ifndef Loan_Bridging_Header_h
#define Loan_Bridging_Header_h
#import "DBSphereView.h"
#endif

I am able to use Frameworks. I have a reference to a well known Framework (Alamofire), and it works great!

我能够使用框架。我有一个众所周知的框架 (Alamofire) 的参考,它工作得很好!

My podfile:

我的播客文件:

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
pod 'DBSphereTagCloud', '~> 1.0'
pod 'Alamofire', '~> 1.1'

Before updating, I had no problems with importing header files.

在更新之前,我在导入头文件方面没有问题。

How do I reference header files in Bridging-Header.h after updating CocoaPods to 0.36.x?

将 CocoaPods 更新到 0.36.x 后,如何引用 Bridging-Header.h 中的头文件?

Thank you!

谢谢!

EDIT:

编辑:

I also tried to create a separate project based on the example "Get Started" from cocoapods.org, without success. After using Frameworks, I can't seem to reference header files in my bridging header file. I must be missing some detail?

我还尝试基于 cocoapods.org 中的示例“Get Started”创建一个单独的项目,但没有成功。使用 Frameworks 后,我似乎无法在桥接头文件中引用头文件。我一定是遗漏了一些细节?

回答by Para

In your Podfile, you specified use_frameworks!.

在您的 中Podfile,您指定了use_frameworks!.

As a result, the Objective-C code you're including as a dependency (DBSphereTagCloud) is packaged as a framework, instead of a static library. Please see CocoaPods 0.36 - Framework and Swift Supportfor more details.

因此,您作为依赖项 ( DBSphereTagCloud)包含的 Objective-C 代码被打包为框架,而不是静态库。有关更多详细信息,请参阅CocoaPods 0.36 - 框架和 Swift 支持

As a consequence, you don't need a bridging header file. It's enough for you to add:

因此,您不需要桥接头文件。补充一下就够了:

import DBSphereTagCloud

in all the Swift files that need that module.

在需要该模块的所有 Swift 文件中。

回答by villy393

I had problems with this. My bridging header wasn't finding pod libs. I ended up finding out that I have to do this.

我遇到了这个问题。我的桥接头没有找到 pod 库。我最终发现我必须这样做。

enter image description here

在此处输入图片说明

回答by Mohammad Nurdin

Try this:

尝试这个:

import  <DBSphereTagCloud/DBSphereView.h>
import  <DBSphereTagCloud/DBSphereView.h>

回答by Byron Coetsee

For me...

为了我...

Original

原来的

import  "<Folder/File.h>"

Change to

改成

import  <Folder/File.h>

回答by stephen

In Project > Build Settings > Search Paths > Header Search Paths

在 Project > Build Settings > Search Paths > Header Search Paths

Add:

添加:

"${PODS_ROOT}/Headers/Public/[Name of folder which pod files are contained in]"

“${PODS_ROOT}/Headers/Public/[pod 文件所在文件夹的名称]”

Do that for every pod you installed

为您安装的每个 pod 执行此操作