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

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

问题描述

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

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 Hope这有帮助!

:D Hope that helps!

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

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