没有使用Xcode 8创建Objective-C桥接标头 [英] Objective-C Bridging Header not getting created with Xcode 8

查看:208
本文介绍了没有使用Xcode 8创建Objective-C桥接标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Objective-C库添加到我的Swift 3项目(Xcode 8 IDE)中。但是目标c接口头文件不会自动生成。我尝试手动添加桥接头,但显示链接错误,提示未找到桥接头.h。任何帮助,将不胜感激:)

I am trying to add objective-c libraries to my Swift 3 project (Xcode 8 IDE). But objective c interface header is not getting generated automatically. I tried to add bridging header manually but showing linking error saying bridging header .h is not found. Any help would be appreciated :)

推荐答案

这里是解决该问题的方法。

Here the solution for the issue.


  • 创建一个新的头文件,并将其命名为 您的项目名称-Bridging-Header.h 。文件
    必须保存到您的项目文件夹中

  • 选择您的xcode项目->选择构建目标->选择构建设置->单击顶部的全部选项->搜索 Swift Compiler-General

  • 选择 Objective-C Bridging Header 项,然后双击其value字段(右侧同一行)。将会出现一个弹出窗口,您可以在其中输入桥接头文件路径(按照以下步骤提供头文件路径)。

  • 打开查找器并将桥接头文件拖放到弹出窗口中。现在它将创建桥接头的绝对路径。要建立相关路径,您可以将路径指定为 $(PROJECT_DIR)/ $(PROJECT_NAME)/ $(PROJECT_NAME)-Bridging-Header.h

  • Create a new header file and name it like "your project name-Bridging-Header.h". The file must be saved to your project folder
  • Select your xcode project -> select your build target -> select build settings -> click the "all" option at the top -> search for Swift Compiler - General
  • Select Objective-C Bridging Header item and double click on its value field (right side of the same row). One popup would appear and there you can enter your bridging header file path (Follow the below steps to provide header file path).
  • Open finder and drag and drop your bridging header file to the popup. Now it will create an absolute path for bridging header. To make relating path, you can give the path as $(PROJECT_DIR)/$(PROJECT_NAME)/$(PROJECT_NAME)-Bridging-Header.h

单击外部以保存该值。做完了!现在,您可以将Objective-C库(例如,#import SVProgressHUD.h)导入桥接文件,并在您的swift项目中开始使用它。

Click outside for the value get saved. Done!! Now you can import your Objective-C libraries (eg. #import "SVProgressHUD.h") to bridging file and start using it in your swift project.

希望这对某人有帮助。 :)

Hope this would be helpful to someone. :)

这篇关于没有使用Xcode 8创建Objective-C桥接标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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