Say I have the following React Native code:
import { NativeModules, Platform } from 'react-native'
if (Platform.OS === 'ios') {
NativeModules.ExampleThing.exampleMethod('example')
}
The following Swift class:
@objc(ExampleThing)
class ExampleThing: NSObject {
private override init() {
print('init')
}
@objc func exampleMethod(_ message: String) -> Void {
print(message)
//do more complex thing
}
}
and the following bridging header:
#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
@interface RCT_EXTERN_MODULE(ExampleThing, NSObject)
RCT_EXTERN_METHOD(exampleMethod:(NSString *)message)
@end
When I run react-native run-ios
, the app starts in the simulator just fine, eg: the effect of exampleMethod
(send a message to Segment.IO) occurs, ergo exampleMethod
is quite clearly getting called correctly. However, for the life of me, I can not find where the print command is printing to. I've also tried os_log
You'd need to run the project through XCode instead of react-native run-ios
, and it'll be shown on the XCode output console.
You can also make use of XCode's breakpoints etc instead of print
statements to help in debugging.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.