Skip to content

Instantly share code, notes, and snippets.

@revskill10
Forked from robertjpayne/RCTSwiftBridgeModule.h
Last active August 29, 2015 14:19
Show Gist options
  • Save revskill10/a3d3c43b6b5c82276527 to your computer and use it in GitHub Desktop.
Save revskill10/a3d3c43b6b5c82276527 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#define RCT_EXTERN_MODULE(objc_name, objc_supername) \
RCT_EXTERN_REMAP_MODULE(objc_name, objc_name, objc_supername)
#define RCT_EXTERN_REMAP_MODULE(js_name, objc_name, objc_supername) \
objc_name : objc_supername \
@end \
@interface objc_name (RCTExternModule) <RCTBridgeModule> \
@end \
@implementation objc_name (RCTExternModule) \
RCT_EXPORT_MODULE(js_name)
#define RCT_EXTERN_METHOD(method) \
RCT_EXTERN_REMAP_METHOD(, method)
#define RCT_EXTERN_REMAP_METHOD(js_name, method) \
- (void)__rct_export__##method { \
__attribute__((used, section("__DATA,RCTExport"))) \
__attribute__((__aligned__(1))) \
static const char *__rct_export_entry__[] = { __func__, #method, #js_name }; \
}
import Foundation
@objc(SwiftReactModule)
class SwiftReactModule: NSObject {
@objc func printMessage(message: String!) {
println("SwiftReactModule::printMessage => \(message)")
}
}
#import "RCTSwiftBridgeModule.h"
@interface RCT_EXTERN_MODULE(SwiftReactModule, NSObject)
RCT_EXTERN_METHOD(printMessage:(NSString *)message)
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment