I'm trying to link my Swift view with my React-Native project. I figured out how to display it, but now when I'm trying to set a property, I'm having this error message:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Switch setMessage:]: unrecognized selector sent to instance 0x7f96b270de70'
In my react-native code, I'm doing:
const SwitchNative = requireNativeComponent('Switch', Switch);
class Switch extends Component {
render() {
return (
<SwitchNative message="message will be" style={this.props.style} />
);
}
}
Then doing this in my SwiftBridge:
// SwiftBridge.h
#import "RCTView.h"
@interface SwitchBridge : RCTView
@property (nonatomic, assign) NSString *message;
@end
// SwiftBridge.m
#import "RCTBridgeModule.h"
#import "RCTViewManager.h"
#import "SwitchBridge.h"
@interface RCT_EXTERN_MODULE(SwitchManager, RCTViewManager)
RCT_EXPORT_VIEW_PROPERTY(message, NSString)
@end
Then finally I have this in my Swift class Switch.swift
:
...
public func setMessage(message: String) {
NSLog("It's working well");
}
...
Not sure why it can't find my setMessage
function.