简体   繁体   English

无法导入桥接头

[英]Unable to import bridging header

Im trying to link an external Objective-C framework, "frameworkSDK", to my swift project. 我试图将外部Objective-C框架“ frameworkSDK”链接到我的快速项目。 However I seem to be getting this error : 但是我似乎收到此错误:

<unknown>:0: error: failed to import bridging header

I've looked at loads of solutions to my problem but non of them seem to work. 我已经研究了很多解决问题的方法,但似乎都没有用。 Here's what I've done so far : 到目前为止,这是我所做的:

  • I've created a "bridingfile.h" at the root of the project and imported "frameworkSDK.frameworkSDK.h" to the file. 我在项目的根目录下创建了一个“ bridingfile.h”,并将“ frameworkSDK.frameworkSDK.h”导入到该文件中。

  • I've made sure Objective-C Bridging Header path was correct under Swift Compiler - Code Generation. 我已经确定在Swift编译器-代码生成下,Objective-C桥接头路径正确。

  • I've changed my framework search paths to the where the "frameworkSDK" is located - Code Generation. 我已经将框架搜索路径更改为“ frameworkSDK”所在的位置-代码生成。

  • Added the path to "bridgingfile.h" to Header Search Paths - Code Generation. 将“ bridgingfile.h”的路径添加到“标题搜索路径-代码生成”中。

  • I've tried to instead create the bridgingfile 1 directory in from the root folder, and then update accordingly. 我试图从根文件夹中创建bridgingfile 1目录,然后进行相应的更新。

Any help would be greatly appreciated! 任何帮助将不胜感激! :) :)

If you are importing an external Objective-C framework, ie one stored in, say, frameworkSDK.framework directory structure (bundle), you should not have to worry about a bridging header. 如果要导入一个外部的Objective-C框架,即一个存储在例如frameworkSDK.framework目录结构(捆绑)中的frameworkSDK.framework ,则不必担心桥接头。 Instead do the following: 而是执行以下操作:

  • Under Build Settings set Framework Search Paths to the parent directory of the frameworkSDK.framework directory. 在“构建设置”下,将“框架搜索路径”设置为frameworkSDK.framework目录的父目录。
  • Also under Build Settings set Runpath Search Paths to $(FRAMEWORK_SEARCH_PATHS) @executable_path/../Frameworks . 同样在“构建设置”下,将“运行路径搜索路径”设置为$(FRAMEWORK_SEARCH_PATHS) @executable_path/../Frameworks
  • In a Swift file where you want to use the Objective-C framework do import frameworkSDK . 在要使用Objective-C框架的Swift文件中,请import frameworkSDK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM