Xcode 6/Beta 4:不支持对框架目标使用桥接头 [英] Xcode 6 / Beta 4: using bridging headers with framework targets is unsupported

查看:26
本文介绍了Xcode 6/Beta 4:不支持对框架目标使用桥接头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级到 Xcode 6 Beta 4 并且有一个我为 Beta 2 中的实时视图创建的框架.由于另一个 swift bug,我需要使用一些 Obj-C 代码.升级时,我收到以下错误:

I just upgraded to Xcode 6 Beta 4 and have a framework that I created for Live Views in Beta 2. Due to another swift bug, I needed to use some Obj-C code. When upgrading though, I get the following error:

错误:不支持对框架目标使用桥接头

error: using bridging headers with framework targets is unsupported

我在发行说明中没有看到任何内容,也没有找到任何其他迁移路径.有没有其他人看到过这个并找到了解决方案?

I have not seen anything in the release notes, or found any other migration path. Has anyone else seen this and arrived at a solution?

我意识到 Beta 3 消除了对实时视图框架的需求,但在我的情况下,如果我可以让它工作,这是有道理的.我可以将它删除作为后备,但如果它们在 Beta 4 中没有完全损坏,我更愿意使用框架.

I realize that Beta 3 eliminated the need for frameworks for live views, but it makes sense in my case if I can get it to work. I can remove it though as a fallback, but would prefer to use a framework if they are not totally broken in Beta 4.

推荐答案

正如错误所述,框架中不允许使用桥接头.混合 &匹配 苹果文档对此的提示.正如他们所说,你需要在你的伞头文件中,导入你想要暴露给 Swift 的每个 Objective-C 头文件".

As the error states, bridging headers are not allowed in Frameworks. The Importing Code from Within the Same Framework Target section of the Mix & Match apple documentation hints at this. As they say, you need to "In your umbrella header file, import every Objective-C header you want to expose to Swift".

但是,我发现您可能还需要公开这些特定的标头.这个答案回顾了为什么以及如何做到这一点:Swift 编译器错误:框架模块内的非模块化头文件".

However, I discovered that you may also need to make those specific headers public as well. This answer reviews why and how to do that: Swift compiler error: "non-modular header inside framework module".

所以,这样做:

  1. 删除您的桥接头文件.
  2. 在框架的构建设置中删除对桥接头文件的引用
  3. 将必要的标题添加到您的保护伞文件 ([ProductName].h)
  4. 在框架的构建阶段"的标题"部分公开包含的文件.
  5. 清理和重建.

注意:伞形头文件"是一个文件(名为 [ProductName].h),通常代表框架的所有公共头文件.它通常只是框架中包含的其他标头的#import 语句列表.在Xcode中,如果你打开UIKit.h,你会看到一个很好的伞形文件示例.

Note: The "umbrella header file" is a file (named [ProductName].h) that generally represents all public headers of a framework. It is usually just a list of #import statements to other headers contained in the framework. In Xcode, if you open UIKit.h, you will see a good example of an umbrella file.

这篇关于Xcode 6/Beta 4:不支持对框架目标使用桥接头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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