Reputation: 7801
When I've added Swift class to Objective-C project it was not included to autogenerated header for swift.
My steps was as following:
import Foundation
class SwiftInObjc : NSObject{
func printHello(){
println("Hello")
}
}
#import "SwiftTest-Swift.h"
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
SwiftInObjc * swiftObj;
}
After that project can't be build because of error:
Use of undeclared identifier "SwiftInObjc"
Header file "SwiftTest-Swift.h" has been created in derived data as expected, but it doesn't contain my swift class.
Note: My case is similar to this question but my class was subclassed from NSObject so it must be another reason. (also I've tried pure Swift class:
import Foundation
@objc class SwiftInObjc {
class func newInstance() -> SwiftInObjc {
return SwiftInObjc()
}
func hello() {
println("hello")
}
}
but it doesn't help, I still have same error)
Upvotes: 2
Views: 559