facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.76k stars 24.29k forks source link

(iOS): Invariant Violation: requireComponent: 'RCTGuidanceView' was not found in the UIManager #28723

Closed bmainz closed 4 years ago

bmainz commented 4 years ago

Description

Hello,

I get the following error message when I try to open the view in the simulator in iOS. In android everything works properly.
I have created a native module that works for android and iOS. However, the UI component RCTGuidanceView does not work for iOS yet.

Invariant Violation: requireNativeComponent: "RCTGuidanceView" was not found in the UIManager.

This error is located at:
    in RCTGuidanceView (at NavigationScreen.js:100)
    in RCTScrollContentView (at ScrollView.js:1038)
    in RCTScrollView (at ScrollView.js:1178)
    in ScrollView (at KeyboardAwareHOC.js:517)
    in KeyboardAwareScrollView (at Content.js:47)
    in RCTSafeAreaView (at SafeAreaView.js:55)
    in SafeAreaView (at Content.js:46)
    in Content (at connectStyle.js:392)
    in Styled(Content) (at NavigationScreen.js:99)
    in RCTView (at Container.js:12)
    in Container (at connectStyle.js:392)
    in Styled(Container) (at NavigationScreen.js:98)
    in NavigationScreen (created by ConnectFunction)
    in ConnectFunction (at SceneView.js:9)
    in SceneView (at createTabNavigator.tsx:67)
    in RCTView (at ResourceSavingScene.tsx:37)
    in RCTView (at ResourceSavingScene.tsx:26)
    in ResourceSavingScene (at createBottomTabNavigator.tsx:157)
    in RCTView (at screens.native.js:101)
    in ScreenContainer (at createBottomTabNavigator.tsx:147)
    in RCTView (at createBottomTabNavigator.tsx:146)
    in TabNavigationView (at createTabNavigator.tsx:228)
    in NavigationView (at createNavigator.js:80)
    in Navigator (at SceneView.js:9)
    in SceneView (at SwitchView.js:12)
    in SwitchView (at createNavigator.js:80)
    in Navigator (at createAppContainer.js:430)
    in NavigationContainer (at App.js:112)
    in StyleProvider (at App.js:111)
    in Provider (at App.js:93)
    in NetworkProvider (at App.js:91)
    in App (at renderApplication.js:40)
    in RCTView (at AppContainer.js:101)
    in RCTView (at AppContainer.js:119)
    in AppContainer (at renderApplication.js:39)

getNativeComponentAttributes
    getNativeComponentAttributes.js:30:4
exports.get
    ReactNativeViewConfigRegistry.js:102:25
renderRoot
    [native code]:0
runRootCallback
    [native code]:0
unstable_runWithPriority
    scheduler.development.js:643:23
callFunctionReturnFlushedQueue
    [native code]:0

I am trying to integrate a HereMaps view with the latest Here Maps SDK (3.15.2). In the pods file the minimum iOS platform version is set to 12.0.

This is my Manager class:

#import <React/RCTViewManager.h>
#import <React/RCTUIManager.h>
#import <React/RCTLog.h>
#import "RCTGuidanceView.h"

@interface RCTGuidanceViewManager : RCTViewManager
@end

@implementation RCTGuidanceViewManager

RCT_EXPORT_MODULE(RCTGuidanceView) // also tried to leave it empty

- (UIView *)view
{
  return [[RCTGuidanceView alloc] init];
}
RCT_EXPORT_VIEW_PROPERTY(lat, double);
// more properties and methods

This is my custom view:

// RCTGuidanceView.h
#import <MapKit/MapKit.h>
#import <NMAKit/NMAMapScheme.h>
#import "React/RCTView.h"
@import NMAKit;
@interface RCTGuidanceView : RCTView <NMANavigationManagerDelegate> // also tried UIView here
 @property double lat;
...

// RCTGuidanceView.m
#import "RCTGuidanceView.h"
@import NMAKit;

@implementation RCTGuidanceView
//...

The JS embedding the native component:

import { requireNativeComponent, ViewPropTypes } from 'react-native'
import PropTypes from 'prop-types'

const RCTGuidanceView = requireNativeComponent('RCTGuidanceView', {
  name: 'RCTGuidanceView',
  propTypes: {
    lat: PropTypes.number,
    //...
    ...ViewPropTypes,
  },
})

export default RCTGuidanceView

React Native version:

System: OS: macOS 10.15.1 CPU: (4) x64 Intel(R) Core(TM) i5-4308U CPU @ 2.80GHz Memory: 21.59 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 12.1.0 - /usr/local/bin/node npm: 6.9.0 - /usr/local/bin/npm SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 IDEs: Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.5 => 0.61.5 npmGlobalPackages: react-native-cli: 2.0.1

bmainz commented 4 years ago

Seems like it was an Xcode problem. Moved the files to another folder, working now.