简体   繁体   English

带有Cocoapods的Objective C iOS项目+ Swift 2 WatchOS项目

[英]Objective C iOS project + Swift 2 WatchOS project with Cocoapods

I've got an Objective-C project , and I recently added a WatchOS 2 project to it which is in Swift 2. 我有一个Objective-C项目,最近我在Swift 2中添加了一个WatchOS 2项目。

From WatchOS project ,I'm accessing an Objective-C class (lets just say Equations.m ) via a bridging header. 从WatchOS项目中,我正在通过桥接标头访问Objective-C类(仅说Equations.m )。 However this Equations.m file imports another library (to be specific HHUnitConverter ) and this HHUnitConverter was added to the project using Cocoapods. 但是,此Equations.m文件导入了另一个库(将是特定的HHUnitConverter ),并且已使用Cocoapods将此HHUnitConverter添加到了项目中。

When I build the WatchOS project I'm getting this error : " HHUnitConverter.h " is not found. 当我构建WatchOS项目时,出现此错误: HHUnitConverter.hHHUnitConverter.h ”。

Isn't it possible to use an Objective-C class via a bridging-header in a Swift class, when that Obj C class has references to another Obj-C classes that were added using cocoapods? 当Obj C类引用使用cocoapods添加的另一个Obj-C类的引用时,是否可以通过Swift类中的桥接头使用Objective-C类? What should I change to make this file available to the compiler? 为了使该文件可用于编译器,我应该进行哪些更改?

I've been tearing my hair out trying to get this working for hours, any advice is appreciated. 我一直在努力尝试使它工作数小时,我一直在撕头发,任何建议都值得赞赏。 Thanks! 谢谢!

Select your watchOS target and go to Build Settings. 选择您的watchOS目标,然后转到“构建设置”。 Set the 'Objective-C Bridging Header' file to the same file as in your iOS target. 将“ Objective-C桥接标头”文件设置为与iOS目标中相同的文件。

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

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