简体   繁体   English

将Objective-C桥接到Swift项目

[英]Bridging Objective-C into Swift Project

I'm trying to put a bridging header file into my Swift project so I can use the Venmo SDK. 我正在尝试将桥接头文件放入Swift项目中,以便可以使用Venmo SDK。 I've placed the header file where I believe it should go and have added it to the Swift Complier - Code Generation section under build settings. 我将头文件放置在我认为应该去的位置,并将其添加到构建设置下的Swift Complier-代码生成部分。

The bridging header is titled BridgingHeader.h and is directly under the project subsection (would post photo but I don't have enough reputation). 桥接头的标题为BridgingHeader.h,位于项目子部分的正下方(会张贴照片,但我的信誉不高)。 It's in the same location as this link: 它位于此链接的相同位置:

在此处输入图片说明

Under the swift compiler - code generation my path to the bridging header is BridgingHeader.h. 在快速编译器下-代码生成我到桥接头的路径是BridgingHeader.h。 Initially I tried to reference the file from the root directory but I still had an error saying error: 最初,我尝试从根目录引用该文件,但仍然出现错误,提示错误:

bridging header '/Users/j9/Desktop/uSell-swift/BridgingHeader.h' does not exist 桥接头'/Users/j9/Desktop/uSell-swift/BridgingHeader.h'不存在

Apparently, the compiler is looking for .../BridgingHeader.h, while the actual name is LearnSwift-Bridging-Header.h. 显然,编译器正在查找... / BridgingHeader.h,而实际名称为LearnSwift-Bridging-Header.h。

By the way, you can avoid these annoyances by adding an ObjC class File->New->Source->Objective C file ... It will create and configure the header for you. 顺便说一句,您可以通过添加ObjC类File->New->Source->Objective C file Source- File->New->Source->Objective C file来避免这些麻烦。它将为您创建和配置标头。

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

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