我在Swift
. 我的目的是Swift
在课堂上使用课堂Objective-C
。我创建了一个Swift
文件。然后是一个Objective-C
文件。我确保Build SettingsObjective-C
中的标头是Test-Swift.h
当我尝试在 Objective-C 文件中导入 Test-Swift.h 时,出现错误 -
未找到“Test-Swift.h”文件。
迅捷类:
import Foundation
@objc class MyTest: NSObject {
func addTest() {
print("test")
}
}
Objective-C 类:
#import "YourTest.h"
#import <Test/Test-Swift.h>
#import "Test-Swift.h" // Error in this line
@implementation YourTest
-(void)testTest {
// This is how I want to use the swift class
MyTest *test = [MyTest new];
[test addTest];
}
@end
框架头文件:
#import <UIKit/UIKit.h>
//! Project version number for Test.
FOUNDATION_EXPORT double TestVersionNumber;
//! Project version string for Test.
FOUNDATION_EXPORT const unsigned char TestVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Test/PublicHeader.h>
构建设置(objective-C 标头):
我已将定义模块设置为是