Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

NativeModules is {} on iOS

$
0
0

Following https://reactnative.dev/docs/native-modules-ios, I'm unable to get NativeModules to contain anything. It's just an empty object (i.e. {}), but it should have the CalendarManager object and associated addEvent() method attached. This is true both for the simulator and my physical device. I was able to get an Android NativeModule working, so it appears to just be an iOS issue.

React Native version: 0.61.5

Podfile

platform :ios, '11.0'require_relative '../node_modules/react-native-unimodules/cocoapods'require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'target 'native' do  rnPrefix = "../node_modules/react-native"  # React Native and its dependencies  pod 'FBLazyVector', :path => "#{rnPrefix}/Libraries/FBLazyVector"  pod 'FBReactNativeSpec', :path => "#{rnPrefix}/Libraries/FBReactNativeSpec"  pod 'RCTRequired', :path => "#{rnPrefix}/Libraries/RCTRequired"  pod 'RCTTypeSafety', :path => "#{rnPrefix}/Libraries/TypeSafety"  pod 'React', :path => "#{rnPrefix}/"  pod 'React-Core', :path => "#{rnPrefix}/"  pod 'React-CoreModules', :path => "#{rnPrefix}/React/CoreModules"  pod 'React-RCTActionSheet', :path => "#{rnPrefix}/Libraries/ActionSheetIOS"  pod 'React-RCTAnimation', :path => "#{rnPrefix}/Libraries/NativeAnimation"  pod 'React-RCTBlob', :path => "#{rnPrefix}/Libraries/Blob"  pod 'React-RCTImage', :path => "#{rnPrefix}/Libraries/Image"  pod 'React-RCTLinking', :path => "#{rnPrefix}/Libraries/LinkingIOS"  pod 'React-RCTNetwork', :path => "#{rnPrefix}/Libraries/Network"  pod 'React-RCTSettings', :path => "#{rnPrefix}/Libraries/Settings"  pod 'React-RCTText', :path => "#{rnPrefix}/Libraries/Text"  pod 'React-RCTVibration', :path => "#{rnPrefix}/Libraries/Vibration"  pod 'React-Core/RCTWebSocket', :path => "#{rnPrefix}/"  pod 'React-Core/DevSupport', :path => "#{rnPrefix}/"  pod 'React-cxxreact', :path => "#{rnPrefix}/ReactCommon/cxxreact"  pod 'React-jsi', :path => "#{rnPrefix}/ReactCommon/jsi"  pod 'React-jsiexecutor', :path => "#{rnPrefix}/ReactCommon/jsiexecutor"  pod 'React-jsinspector', :path => "#{rnPrefix}/ReactCommon/jsinspector"  pod 'ReactCommon/jscallinvoker', :path => "#{rnPrefix}/ReactCommon"  pod 'ReactCommon/turbomodule/core', :path => "#{rnPrefix}/ReactCommon"  pod 'Yoga', :path => "#{rnPrefix}/ReactCommon/yoga"  pod 'DoubleConversion', :podspec => "#{rnPrefix}/third-party-podspecs/DoubleConversion.podspec"  pod 'glog', :podspec => "#{rnPrefix}/third-party-podspecs/glog.podspec"  pod 'Folly', :podspec => "#{rnPrefix}/third-party-podspecs/Folly.podspec"  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'  # Other native modules  # Automatically detect installed unimodules  use_unimodules!  # react-native-cli autolinking  use_native_modules!  # https://stackoverflow.com/a/59564933  use_frameworks!end

Native.js

import { NativeModules } from "react-native";...console.log(NativeModules); // {}

CalendarManager.h

#import <React/RCTBridgeModule.h>@interface CalendarManager : NSObject <RCTBridgeModule>@end

CalendarManager.m

#import "CalendarManager.h"#import <React/RCTBridgeModule.h>@implementation CalendarManagerRCT_EXPORT_MODULE();RCT_EXPORT_METHOD(addEvent:(NSString *)name location:(NSString *)location){  RCTLogInfo(@"Pretending to create an event %@ at %@", name, location);}@end

Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>