I can't access my Swift Singleton Class from my Objective-C ViewController.
Xcode does recognize my Swift Class, it builds, so I don't think it is a bridging header issue.
Here is my Swift Singleton Class :
@objc class MySingleton : NSObject {
static let shared = MySingleton()
private override init() {}
}
And then in my .m file I import this header :
#import "myProject-Swift.h"
And use the Singleton this way :
MySingleton *testSingleton = [MySingleton shared];
or this way :
[MySingleton shared];
It does recognize the MySingleton class type, but I can't access any functions or properties of this class.
What am I missing? All the similar posts didn't help.
EDIT: I made a test function
func testPrint() {
print("Singleton worked")
}
And called it this way in the objective-c file :
[[MySingleton shared] testPrint];
No known instance for selector 'testPrint'