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

查看:23
本文介绍了未使用 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 项目并双击其值字段(同一行的右侧).将出现一个弹出窗口,您可以在那里输入您的桥接头文件路径(按照以下步骤提供头文件路径).
  • 打开 finder 并将您的桥接头文件拖放到弹出窗口中.现在它将为桥接头创建一个绝对路径.要制作相关路径,您可以将路径指定为 $(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天全站免登陆