Trying to print to console (terminal) from the iOS code in React Native
In iOS folder, under my RN project:
RNLogger.h file
#import <React/RCTBridgeModule.h>
@interface RNLogger : NSObject <RCTBridgeModule>
@end
RNLogger.m file
#import <React/RCTLog.h>
#import "RNLogger.h"
@implementation RNLogger
RCT_EXPORT_MODULE();
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(printLog)
{
RCTLog(@"SOME LOG");
return @"";
}
@end
And on the RN side:
import {NativeModules} from 'react-native';
NativeModules.RNLogger.printLog();
Does not work for me. Also I've tried with print, printf and NSLog and nothing seems to work.
Basically I want to print on RN console same as console.log would do..
What the right way to do so?