React Native Fetch Blob - undefined is not an object (evaluating 'RNFetchBlob.DocumentDir') - ios

Disclaimer
I have looked at the trouble shooting page of the wiki, however I still cannot fix the problem I am having.
RN version:
react-native-cli: 2.0.1
react-native: 0.43.4
My code:
import FileUploader from 'react-native-file-uploader'
and
<Button
onPress={() => RNFetchBlob.fetch('POST', 'http://localhost:8000/upload', {
'Content-Type' : 'application/octet-stream'
}, RNFetchBlob.wrap('./tempImageStore/image.jpg'))
}
title={'Upload File'}
/>
Error I am getting:
What I did to install react-native-fetch-blob:
1) npm install --save github:wkh237/react-native-fetch-blob-package#master
2) react-native link
Background info:
I have tried importing it with both import RNFetchBlob from 'react-native-fetch-blob' and var RNFetchBlob = require('react-native-fetch-blob').default
I have tried installing it with the above code and also with npm install --save react-native-fetch-blob
I am trying this on the IOS emulator.
Thank you in advance for your help!

After linking you need to run
pod update
inside ios folder

So it looks like the module isn't importing. Obvious I know, I can only think of a few things to help seeing as that project looks fairly popular and stable.
I noticed that you're requiring 'react-native-file-uploader' but using 'react-native-fetch-blob'. I'm assuming this is a mistake. You could also try, if you haven't:
var RNFetchBlob = require('react-native-fetch-blob')
Now assuming you're correctly importing it, try one of the following and then restart x-code:
If you haven't already restart the packager. I recall having to restart the packager every time I installed a new module.
If that doesn't work, try installing deleting it from your node modules (just to be safe) and installing with cocoa pods which will handle all of the linking for you.

If you are using React Native >= V.060 nothing to do
If you are using React Native <= 0.59
Check this link : https://github.com/wkh237/react-native-fetch-blob/wiki/Manually-Link-Package

Is part 2 of the installation actually
react-native link
? I think it should be
react-native link github:wkh237/react-native-fetch-blob-package#master

first it has changed to rn-fetch-blob https://github.com/joltup/rn-fetch-blob
then when you install it then Do the linking manually, it worked for me
https://github.com/joltup/rn-fetch-blob/wiki/Manually-Link-Package

Related

'react/bridging/CallbackWrapper.h' file not found in React Native

I am trying to setup my React Native app on iOS, but on build, I am always getting this error:
'react/bridging/CallbackWrapper.h' file not found
I have been investigating on my own and found a few people with the same problem:
https://github.com/mrousavy/react-native-vision-camera/issues/1121
https://github.com/facebook/react-native/issues/34102
I have tried everything in these answers but no luck. Since it seems related to React Native Vision Camera, I also did everything stated in their troubleshooting page.
Unforrunately I still get the error. I built the project both using npx react-native run-ios (which throws an endless error) and using XCode itself, where I could find the real error.
Can you help me? The app works perfectly in Android. Thanks!
If nothing of the links I pasted in the question work, what finally worked for me was:
Updgrade React Native to >= 0.69.3 (my version was 0.69.0). To do that npx react-native upgrade.
Delete Pods folder and Podfile.lock from iOS folder. Run pod install.
And then building the project again.
The way to fix the problem is to comment-out the line :
s.header_dir = "react/bridging"
in
/node_modules/react-native/ReactCommon/React-bridging.podspec

UMModuleRegistryAdapter.h not found when running React Native app in iOS simulator

I have a simple React Native app that I've been testing on Android and now want to test on iOS. It's using React Navigation.
I ran npm run ios but I'm getting the following error:
info In file included from
/Users/rbbit/reactnative/testproj1/ios/testproj1/main.m:10:
/Users/rbbit/reactnative/testproj1/ios/testproj1/AppDelegate.h:9:9: fatal error: 'UMReactNativeAdapter/UMModuleRegistryAdapter.h' file not found
#import <UMReactNativeAdapter/UMModuleRegistryAdapter.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
info 1 error generated.
I opened XCode but I'm basically getting the same message, nothing else that would help me debug this.
I do see that there is a package called react-native-adapter (https://github.com/expo/expo/tree/master/packages/%40unimodules/react-native-adapter), however I'm hesitant to just install this since I followed the instructions on how to include react-navigation and didn't mention that, assuming this is related.
Also, that page says If you are using react-native-unimodules, this package will already be installed and configured!, and react-native-unimodules already is in my dependencies.
Any pointers on how to solve this? Thank you!
For latest RN versions (RN 0.60+) errors like this should be fixed with the auto-linking and just running a pod install.
For older versions you should try:
react-native link in the root folder of your project
Then in Xcode Product->Clean Build folder, restart JS server and attempt to rebuild.
If still not working double check the configs from here:
https://github.com/unimodules/react-native-unimodules
and the App.delegate from here:
https://gist.github.com/brentvatne/1ece8c32a3c5c9d0ac3a470460c65603
Sources:
Pod install reminder was first suggested by Sandy in the below comment
pod install didn't work for me until I added these lines to my pod file:
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
And
use_unimodules!(modules_paths: ['../node_modules'])
Then do a pod install.
Example: https://gist.github.com/sjchmiela/6c079f2173938a9a61a7c6f053c45000
I had this exact same error with everything configured correctly, everything in the other answers done and all the unimodules installation steps already done, on a project that had worked for months, building it on a new computer. It turned out the reason was because I was simply using the wrong file in xCode.
I had opened the .xcodeproj file when I should have opened and run the build from the .xcworkspace file.
Everything seemed to work as normal apart from this error, which made it look like a configuration problem rather than a simple "you opened the wrong file" problem. Hopefully if someone else makes the same mistake, this will save them a few hours of fruitless tinkering.

Requiring unknown module "498" error in ReactNative getting started example

I'm trying to build and run an iOS simulator version of the getting started React Native project from the instructions at:
https://facebook.github.io/react-native/docs/getting-started.html
The app launches in the XCode simulator, displays it's window very briefly but then an exception occurs that opens a red screen with the message
"Requiring unknown module "498".If you are sure the module is there,
try restarting Metro Bundler. You may also want to run yarn, or npm
install (depending on your environment).
loadModuleImplementation require.js:176:29
viewPropTypes.js:15:30
loadModuleImplementation require.js:212:12
View.js:20:22
loadModuleImplementation require.js:212:12
AppContainer.js:22:13"
etc
Line 15 of ViewPropTypes is
const PlatformViewPropTypes = require('PlatformViewPropTypes');
Line 20 of node_modules/react_native/Libraries/Components/Views/View.js is
const ViewPropTypes = require('ViewPropTypes');
Note: There is another, 15 line View.js files in the directory structure at node_modules/react_native/lib/ it's basically a stub containing
// This is a forwarding module to allow React to require React Native internals
// as node dependency
module.exports = require('View');
I'm on the latest of everything, MacOS High Sierra (10.13.4), XCode 9.3 with 9.3 command line tools installed. I've tried running yarn and npm install, and a fresh install. Obviously I have NPM and Watchman installed. Any ideas why the stock example won't run for me?
Newbie mistake. I had previously attempted to build a different React Native project in a different directory, and Metro Bundler was still pointed at the previous project. As the error message suggested, restarting Metro Bundler fixed the problem.
Also didn't realize the errors in the exception screen were tappable, they take you right into the Metro Bundler terminal process for more detail. Hope this helps someone else too!
In my case, just close all the related process, and re-run react-native run-android solved the problem.
refer to: https://github.com/facebook/react-native/issues/11568
I had the same issue.
In my case, while creating a reusable component, I wasn't importing React into the file,as I was not using them(in functional component) in the component file.
Turns out that jsx to React Element conversion happens per file/module basis, so we should import React and component in every file.
Including Both React and Component normally, solved the problem.
For me I got "955" error. And a simple solution was to
import React, {Component} from "react";

RN 0.38.0 React/RCTBridgeModule.h' file not found

This is a long shot, but I've taken over a project done in RN v .38 and I need to update a library and resolve the build issues without updating the version of react native. I'm trying to update the react-native-aws-cognito-js library and while it looks to be compatible with the formatting change of import statements, I'm still not able to get it to build on IOS. Android is fine.
To reproduce my issue I did the following:
react-native init sample --version 0.38.0
cd sample
npm install react-native-aws-cognito-js
react-native link react-native-aws-cognito-js
react-native run-ios
Which fails with:
/node_modules/react-native-aws-cognito-js/ios/RNAWSCognito.h:4:9:
fatal error: 'React/RCTBridgeModule.h' file not found #import
Mobile and RN development is not my wheelhouse, but I'm hoping there is some sort of xcode configuration or tricks I can do to get this working and avoid a major overhaul. Running an upgrade to >.40 would probably take too long and also cause other compatibility issues that I don't have the time to resolve.
Note: I have tried the suggestions in `React/RCTBridgeModule.h` file not found

react-native undefined is not an object (evaluating RCCManager.setRootController)

I'm trying to make a simple react-native app with redux and redux-saga tie-ins. Unfortunately, when I try to run the app (whether using react-native run-ios or running through Xcode, I get the following error:
Strangely enough, when I ported things like the Counter example for redux-saga to react-native or other examples I don't have this issue. I'm wondering if someone could help point to where things could be going wrong?
So turns out I just needed to link some more libraries together.
Reinstalling these components helped:
npm install --save react-native
and
npm install --save react-native-controllers
followed by rnpm link fixed the issue
Here is another solution based on my own failure:
Through rechecking iOS installation doc, I found out some tricky differences in the #4 requirement:
It clearly says project row instead of target row. This time I selected 'project' row and add do what the #4 instruction told to do. Then it solved the problem. Hopefully my solution will be found helpful.
I faced a similar problem and it was because somehow the setup I made for the Xcode project were lost, so following the instructions I made them again and the problem was solved.

Resources