Swift 桥接头导入问题 [英] Swift Bridging Header import issue

查看:36
本文介绍了Swift 桥接头导入问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照说明,我创建了一个桥接头并添加到我的项目中.不幸的是,发生了以下错误:

Following instructions, I've created a bridging header and added to my project. Unfortunately, the following error occurred:

:0: 错误:无法导入 Objective-C 标头 '---path--to---header/..h'

:0: error: could not import Objective-C header '---path--to---header/....h'

在构建设置中,我将标题搜索路径字符串添加到桥接头的位置,但没有任何帮助.

In build settings I added header search path string to the location of bridging header, but nothing helped.

有人遇到过这个问题吗?

Has anyone experienced this problem?

推荐答案

小心将文件添加到您的错误所在的文件夹中!我犯了同样的错误,如果你从 Xcode 创建文件,它会转到文件夹:Project->Project->Header.h

Be careful to add the file to the folder that your error is complaining! I've made the same mistake, if you create the file from Xcode, it will go to the folder: Project->Project->Header.h

而 Xcode 正在寻找 Project->Header.h

And Xcode is looking for Project->Header.h

这意味着您需要将文件放在您的项目文件夹中(ProjectName->ProjectNameFolder)!

That means you need to put the file inside your project folder (ProjectName->ProjectNameFolder)!

希望有帮助;)

更新:我不确定我是否明白你的意思,但试试这个来解决你的问题:
1. 删除您迄今为止创建的所有桥接文件.
2.选择项目的主文件夹,然后点击新文件->iOS->头文件.
3. 在创建的头文件中写入您的导入.
4. 在 Xcode->Build Settings 中选择项目,在搜索字段中输入:bridging 并在键 SWIFT_OBJC_BRIDGING_HEADER 中输入您的头文件的名称或路径!

UPDATED: I'm not sure if I got what you mean, but try this to solve your problem:
1. Delete all your bridging files that you created until now.
2. Select the main folder of project and hit new file->iOS->Header file.
3. Write your imports in the header file created.
4. Select the project inside Xcode->Build Settings, type in search field: bridging and put in the key SWIFT_OBJC_BRIDGING_HEADER the name of your header file or the path to it!

如果您按照此步骤操作,您的头文件将在正确的位置创建!

If you follow this steps, your header file will be created at the correct location!

:D 希望有帮助!

这篇关于Swift 桥接头导入问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆