首页 > 解决方案 > 找不到目标 C 桥接头文件

问题描述

我有一个AppState使用 swift 类对象的类名

#import "Sonic-Swift.h"

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

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

但在导入此文件后,应用程序在“#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'

标签: iosobjective-cswiftobjc-bridging-header

解决方案


import "Sonic-Swift.h" 

应该只在.m文件中。

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

@class MySwiftClass;

推荐阅读