import尝试导入使用nativeModule创建的我自己的模块(IOS-RN)时未定义

时间:2018-11-14 20:17:25

标签: react-native react-native-ios react-native-native-module react-native-linking

我创建了用于包装MixPanel SDK的react-native-library,但不适用于IOS,仅适用于Android。当尝试在android native模块中导入时,可以识别我的模块“ RNMixPanel”,但是每次从ios尝试导入时,该值均未定义。 (以前我链接了此模块)

“反应”:“ 16.6.1”, “ react-native”:“ 0.57.5”,

Create method to export in IOS folder 


#import "RNMixPanel.h"
#import "Mixpanel/Mixpanel.h"

@implementation RNMixPanel

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(createInstance){
     Mixpanel *mixpanel = [Mixpanel sharedInstance];
    [mixpanel sharedInstanceWithToken:@"3XXXXXXXXXXXXXXXX3"];
}
@end



Wrap NativeModule. Index library



import { NativeModules } from 'react-native';

const { RNMixPanel } = NativeModules;

export default {
    createInstance: function () {
        console.log(RNMixPanel)
    }
}

0 个答案:

没有答案