繁体   English   中英

如何创建 Objective-C 桥接 header?

[英]How do I create an Objective-C bridging header?

我正在关注将 OneSignal 添加到 React Native 的指南,其中有一节说:

Open NotificationService.m or NotificationService.swift and replace the whole file contents with the code below:

<provides code to add>

If you are using Swift, make sure to create a separate Objective-C Bridging Header for your OneSignalNotificationExtensionService and add the following import:

#import "RCTOneSignalExtensionService.h" Then you need to tell your Xcode project settings what your bridging header is named, like this.

我将他们提供的代码添加到NotificationService.swift因为这是我的项目中存在的两个文件中唯一的一个。 所以我假设我正在“使用 swift”,正如他们所说的那样。 问题是,当他们说要create a separate Objective-C Bridging Header时,我不知道该怎么做。 All I've been able to find online is that when you import Objective-C code into your swift project, Xcode should automatically prompt you to create a bridging header. Xcode 并没有为我做到这一点。

有谁知道我如何创建一个 Objective-C 桥接 header?

您必须创建一个新目标 c class:

您选择新文件

然后

选择可可触摸类

然后你命名它并在语言中指定为 objective-c class

选择objective-c作为语言

然后你 select 你的目录并点击创建。 此时 xcode 将询问您是否要创建桥接 header。 是的,这样做。

在此处输入图像描述

最后,它在您的项目中应该或多或少像这样。

任务完成

希望对你有帮助。

暂无
暂无

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

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