NativeModules.MyNativeModule在react native 0.61.2的iOS中未定义
我有一个我正在写的本地图书馆。它停留在本地作为现在,所以我安装它与NativeModules.MyNativeModule在react native 0.61.2的iOS中未定义,ios,reactjs,react-native,Ios,Reactjs,React Native,我有一个我正在写的本地图书馆。它停留在本地作为现在,所以我安装它与 纱线添加../MyNativeModule 然后在我的代码中,我将其作为 const MyNativeModule=NativeModules.MyNativeModule。这在android上运行良好,但在iOS上则不起作用。我将MyNativeModule作为undefined获取 我的本机模块: android ... ios MyNativeModule.h MyNativeModule.m
纱线添加../MyNativeModule
然后在我的代码中,我将其作为
const MyNativeModule=NativeModules.MyNativeModule代码>。这在android上运行良好,但在iOS上则不起作用。我将MyNativeModule
作为undefined
获取
我的本机模块:
android
...
ios
MyNativeModule.h
MyNativeModule.m
MyNativeModule.xcodeproj
index.js
MyNativeModule.podspec
MyNativeModule.h
#import <React/MyNativeModule.h>
@interface MyNativeModule : NSObject <RCTBridgeModule>
@end
我的播客规格:
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Pod::Spec.new do |s|
s.name = "MyNativeModule"
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.authors = package['author']
s.homepage = package['repository']['url']
s.platform = :ios, "9.0"
s.ios.deployment_target = '9.0'
s.source = { :git => "" }
s.source_files = "ios/**/*.{h,m}"
s.dependency 'React'
end
我试过:
1. Removed and re-installed everything.
2. Cleared caches of pods and metro.
3. I tried changing the s.source on my podspec to the local repo.
4. I tried changing the s.source_files to "ios/*.{h,m}"
我已经试了一整天了,但什么都没用。一些帮助会很好。好吧,看起来我必须在MyNativeModule.m
中实现一个函数。因此,如果没有至少一个函数,它就无法工作
RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location)
{
RCTLogInfo(@"Pretending to create an event %@ at %@", name, location);
}
@end
RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location)
{
RCTLogInfo(@"Pretending to create an event %@ at %@", name, location);
}
@end