I have a Swift framework in which I have an Objective-C file. From that file I want to access a method which is declared as internal. I know that I can change it to public to make it available. But I don't want to expose it to the client app. Is there any way to achieve this?
In .swift:
@objc internal class func callBack(str: String) {
print("Swift method was called | Passed value: " + str)
}
In .m:
- (void)callSwiftFunc {
// This is not available, only if I set public in Swift
[SwiftClass callBackWithStr:@"blabla"];
}
You can explicitly set the objc selector and then add a category which declares the method:
replace @objc
with @objc(callBackWithStr:)
, then simply add a forward declaration:
@interface SwiftClass ()
+ (void)callBackWithStr:(NSString *)string;
@end