【问题标题】:Objective C bridging header file not found找不到目标 C 桥接头文件
【发布时间】:2018-05-24 10:49:28
【问题描述】:

我有一个类名AppState,它正在使用一个快速的类对象

#import "Sonic-Swift.h"

@interface AppState : NSObject
@property (class) NSMutableArray<"Swift class" *> *entity;

现在我需要在 swift 文件中使用这个类 (AppState)。所以我试图在桥接头中导入这个类。

但在导入此文件后,应用程序会在“#import "Sonic-Swift.h"”行“找不到文件”上报错。

failed to emit precompiled header '/Users/krishna_mac_2/Library/Developer/Xcode/DerivedData/Apps-gqelclyzwvyomhcchmjjsejrznaw/Build/Intermediates.noindex/PrecompiledHeaders/Sonic-Bridging-Header-swift_3RJ3MQEOEFTPD-clang_26Q2UBYWMY12Y.pch' for bridging header '/Users/krishna_mac_2/Documents/Documents/Documents/Documents/Documents/Github/Sonic/iOS/Sonic/Sonic-Bridging-Header.h'

【问题讨论】:

  • #import "Sonic-Swift.h" 它应该在 .m 文件中,还有一件事你不需要那个头文件,除非你在你的 AppState 类
  • @PrashantTukadiya 我正在 AppState.h 类中创建 swift 文件对象,这就是我需要导入它的原因。
  • 然后试试@class MySwiftClass;不要在.h中添加头文件
  • 谢谢,我试试

标签: ios objective-c swift objc-bridging-header


【解决方案1】:
import "Sonic-Swift.h" 

应该只在.m 文件中。

如果你想在.h 文件中使用 Swift 类,那么你应该使用

@class MySwiftClass;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-17
    相关资源
    最近更新 更多