我有一个旧的Objective-C项目,我想调用新的Swift函数和对象,我创建了文件"<ProjectName>-Bridging-Header.h
"和"<ProjectName>-Swift.h
"
对我来说,从Swift调用Objective-C函数很容易,但反向调用有问题.
所以我创建了一个简单的类"System.Swift"
import Foundation
@objc class System : NSObject {
@objc func printSome() {
println("Print line System");
}
}
现在我试着遵循文档here,在<...>-Swift.h
文件中我写了这个
@class System;
@interface System : NSObject
-(void)printSome;
@end
我已经在我的Objective-C类中导入了它.此时,在我的Objective-C代码的Objective C类(当前为UIViewController)中,我try 调用"printSome"方法:
- (void)viewDidLoad
{
[super viewDidLoad];
System * sis = [[System alloc] init];
[sis printSome];
//any additional setup after loading the view from its nib.
}
现在我有以下错误:
架构i386的未定义符号:"OBJC_CLASS$_系统",