React Navigation - "Cannot read property 'State' of undefined" even though gesture-handler is installed & linked - ios

Problem
I get the error "Cannot read property 'State' of undefined" when trying to use a stack navigator in React Navigation. Switch and bottomTabNavs are working perfectly fine.
If anyone knows how to solve this problem that would be amazing!
What I've tried
I've already checked to make sure react-native-gesture-handler is installed and linked properly.
My Package.json:
{
"name": "app",
"version": "5.1.0",
"private": true,
"devDependencies": {
"babel-jest": "23.6.0",
"fs-extra": "^6.0.1",
"jest": "23.6.0",
"metro-react-native-babel-preset": "0.49.2",
"react-test-renderer": "16.7.0",
"reactotron-react-native": "^3.2.0",
"replace-in-file": "^3.4.2"
},
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios --simulator=\"iPhone X\"",
"apk": "cd android && ./gradlew assembleRelease",
"rename": "node ./bin/rename.js",
"start": "react-native start",
"test": "jest"
},
"jest": {
"preset": "react-native"
},
"dependencies": {
"axios": "^0.18.0",
"lodash": "^4.17.11",
"react": "16.6.3",
"react-native": "0.58.0-rc.2",
"react-native-firebase": "^5.2.0",
"react-native-gesture-handler": "^1.1.0",
"react-native-rate": "^1.1.6",
"react-native-sensitive-info": "5.2.9",
"react-native-splash-screen": "^3.2.0",
"react-native-status-bar-height": "^2.3.1",
"react-native-table-component": "^1.2.0",
"react-navigation": "^3.3.2"
}
}

The issue was that the pod file was not installed even though react-native link indicated the package was successfully linked.
To solve the issue follow these steps:
cd ios
Pod install
Clean ios folder
Run application

Related

error Command failed with exit code 1 with react-native and Xcode library not found

I'm getting the following error when I clone react native project from github, yarn install, cd ios && pod install, cd .. , yarn ios . And/or when I ran react-native run-ios as well:
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
In addition, when I open the .xcworkspace in the Xcode, I get the error:
library not found for BugsnagReactNative
The package.json is:
{
"name": "proj",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"build": "CI= npm run build",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#bugsnag/react-native": "^7.16.2",
"#react-native-async-storage/async-storage": "^1.15.6",
"#react-native-community/checkbox": "^0.5.8",
"#react-native-community/datetimepicker": "^4.0.1",
"#react-native-community/masked-view": "^0.1.11",
"#react-native-community/netinfo": "^6.0.0",
"#react-navigation/bottom-tabs": "^6.0.5",
"#react-navigation/native": "^6.0.2",
"#react-navigation/stack": "^6.0.7",
"amazon-cognito-identity-js": "^5.1.0",
"aws-amplify": "^4.2.4",
"axios": "^0.21.1",
"package": "^1.0.1",
"prop-types": "^15.7.2",
"react": "17.0.2",
"react-native": "0.66.3",
"react-native-carousel": "^0.12.0",
"react-native-codegen": "^0.0.7",
"react-native-collapsible": "^1.6.0",
"react-native-date-picker": "^4.1.1",
"react-native-dropdown-picker": "^5.1.23",
"react-native-exit-app": "^1.1.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-mask-input": "^1.0.3",
"react-native-modal-dropdown": "^1.0.1",
"react-native-month-year-picker": "^1.8.0",
"react-native-safe-area-context": "^3.3.0",
"react-native-screens": "^3.13.1",
"react-native-select-dropdown": "^1.1.0",
"react-native-snap-carousel": "^3.9.1",
"tcomb-form-native": "^0.6.20",
"toggle-switch-react-native": "^3.2.0",
"yarn": "^1.22.17"
},
"devDependencies": {
"#babel/core": "^7.15.0",
"#babel/runtime": "^7.15.3",
"#bugsnag/source-maps": "^2.3.1",
"#react-native-community/eslint-config": "^3.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "26.6.3",
"eslint": "7.32.0",
"jest": "^27.0.6",
"metro-react-native-babel-preset": "^0.66.2",
"react-test-renderer": "17.0.2"
},
"jest": {
"preset": "react-native"
}
}
The solutions below I tried didn't work.
yarn add global #bugsnag/react-native-cli
change rct-folly deployment target to 9.0
set Build Active architecture Only to Yes
click and install ios 13.0 simulator in xcode
delete the search paths in build settings delete pods folder, and installed pods again
remove all lines in the 'Other Linker Flags' list BUT only if $(inherited) is at the top
pod update
reinstall ruby/gem
uninstall and reinstall Cocoapods
rm -rf node_modules, yarn cache clean
remove the podfile.lock and the pod, re-install them
sudo arch -x86_64 gem install ffi, arch -x86_64 pod install
uninstall and reinstall watchman
check node version, react native version, and bugsnag version
comment out bugsnag dependencies from package. json
fresh install multiple times
try this
npx #bugsnag/react-native-cli init
and check bugsnag documentation as you need to have a project available on bugsnag

"tried to register two views with the same name RNCSafeAreaProvider" error on IOS

I'm receiving the following error when running react native app using expo on IPhone (on android it's working correctly)
An image of the error is attached.
In addition, this is my package.json file:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"#expo/vector-icons": "^12.0.4",
"#react-native-community/masked-view": "^0.1.10",
"axios": "^0.21.1",
"expo": "~40.0.0",
"expo-app-loading": "^1.0.1",
"expo-font": "^9.0.0",
"expo-status-bar": "~1.0.3",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^2.0.1",
"react-native-safe-area-context": "3.1.9",
"react-native-screens": "^2.18.1",
"react-native-web": "~0.13.12",
"react-navigation": "^4.4.4",
"react-navigation-header-buttons": "^7.0.0",
"react-navigation-stack": "^2.10.4",
"react-redux": "^7.2.3",
"redux": "^4.0.5"
},
"devDependencies": {
"#babel/core": "^7.9.0" },
"private": true
}
Any idea will be appreciated.
you have two versions of react-native-safe-area-context installed in your app. remove react-native-safe-area-context from your dependencies and run expo install react-native-safe-area-context
In this link you can find the solution approved by a collaborator.
In my case, problem persisted and I did as suggested in the link above but I skip steps 2 and 5. I kept expo version in 4.1.0.
delete node_modules and your lockfile (package-lock.json /
yarn.lock)
change the expo package version in package.json to 38.0.8
remove react-native-safe-area-context from your package.json
run yarn or npm install
run expo install react-native-safe-area-context
try running
cd ios && pod install

when I run this NPX POD-INSTALL it gives me this COCOAPODS IS NOT SUPPORTED IN THIS PROJECT #ReactNative

Package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"#react-native-community/masked-view": "^0.1.10",
"#react-native-firebase/app": "^8.4.2",
"#react-navigation/native": "^5.6.1",
"#react-navigation/stack": "^5.6.2",
"expo": "^39.0.3",
"expo-ads-admob": "~8.3.0",
"expo-av": "~8.6.0",
"expo-image-picker": "~9.1.0",
"expo-status-bar": "^1.0.0",
"expo-web-browser": "~8.5.0",
"firebase": "7.9.0",
"lottie-react-native": "~2.6.1",
"react": "~16.11.0",
"react-dom": "~16.11.0",
"react-native": "^0.63.3",
"react-native-appearance": "~0.3.3",
"react-native-dark-mode": "^0.2.2",
"react-native-elements": "^2.3.2",
"react-native-gesture-handler": "^1.6.1",
"react-native-hide-show-password-input": "^1.1.0",
"react-native-material-ripple": "^0.9.1",
"react-native-paper": "^4.0.1",
"react-native-reanimated": "^1.9.0",
"react-native-safe-area-context": "^3.0.2",
"react-native-screens": "^2.9.0",
"react-native-tts": "^3.2.0",
"react-native-vector-icons": "^7.1.0",
"react-native-web": "~0.11.7",
"react-navigation": "^4.4.0",
"react-navigation-stack": "^2.8.2",
"yarn": "^1.22.10"
},
"devDependencies": {
"#babel/core": "^7.8.6",
"#types/react": "~16.9.41",
"#types/react-native": "~0.62.13",
"typescript": "~3.9.5"
},
"private": true
}
This is Package.json of my project in react native. How to install cocoa pods in this project I read somewhere that when using expo dependencies in the project you can't install cocoapods in the project so how to install cocoa pods when using expo dependencies
You just can't install cocoa pods when using expo, that simple. If you need some library from react native community that needs to install cocoa pods, you just can't use it unless expo made its own. You can check if that library is available for expo here: https://docs.expo.io/versions/latest/
Almost everything from react native community has its own expo version if needed.
To install, use $ expo install <module-name>.
You should use expo bare workflow if you want to add react native librairies which are not included in expo client already.
With Expo bare workflow you can still use expo modules like expo-ad-mobs and even expo client if you have some fail over strategy for your newly added librairies.
https://docs.expo.io/bare/exploring-bare-workflow/
But you will have to build the app yourself, while expo managed workflow lets you use expo cli & infrastructure to build your ipa/apk.
If you just want to build the app and not add any other library, just use expo cli commands like expo build:ios

React/RCTDefines.h file not found in RCTBridgeModule.h

I was using Expo and I separated expo eject for module use.
And I tried pod install in iOS file. it was work.
Pod installation complete! There are 51 dependencies from the Pod file
and 63 total pods installed.
But An error occurred when the Xcode was opened and the build and run button was pressed.
package.json:
{
"name": "testgame",
"version": "0.1.0",
"private": true,
"devDependencies": {
"babel-cli": "6.26.0",
"babel-plugin-module-resolver": "^3.1.1",
"babel-preset-es2015": "6.24.1",
"jest-expo": "27.0.0",
"react-native-scripts": "1.14.0",
"react-test-renderer": "16.3.1"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "jest"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"#expo/vector-icons": "^8.1.0",
"bignumber.js": "^8.1.1",
"crypto-browserify": "^3.12.0",
"eth-lightwallet": "^3.0.1",
"ethereumjs-tx": "^1.3.7",
"ethereumjs-util": "^6.0.0",
"ethereumjs-wallet-react-native": "^0.6.7",
"expo": "^30.0.0",
"expokit": "^1.8.0",
"formik": "^1.3.2",
"js-sha3": "^0.8.0",
"native-base": "^2.8.2",
"node-libs-browser": "2.1.0",
"react": "16.3.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz",
"react-native-confirmation-code-input": "^1.0.4",
"react-native-fast-crypto": "^1.8.1",
"react-native-fetch-blob": "git+https://github.com/HCL-HO/react-native-fetch-blob-expo.git",
"react-native-fs": "^2.13.3",
"react-native-keychain": "^3.1.2",
"react-native-pin-view": "^2.2.1",
"react-native-secure-randombytes": "^3.0.0",
"react-native-touch-id": "^4.4.1",
"react-navigation": "3.0.4",
"web3": "1.0.0-beta.34",
"yup": "^0.26.6"
}
}
Xcode Version: 10.2.1
I've never used Xcode before, so I'm a beginner. Please explain it in detail. I'd appreciate it if you could explain it with a screenshot.
I made a podsec myself and solved it.
This is not in the official document and requires a fundamental solution from the module developer.
This solution creates a lot of Warning. There's nothing wrong with the code.
Remove react-native-secure-randombytes path from Header Search Path
Unlink react-native-secure-randombytes module - react-native unlink react-native-secure-randombytes
Added react-native-secure-randombytes.podspec from this link
Added next code into pod file:
pod 'react-native-secure-randombytes', :path =>
'../node_modules/react-native-secure-randombytes'
do `pod install'

facing issue in installing new package

I am using react-native-base for using react-native components.
I have already installed previously
react-native-document-picker
react-native-fcm
react-native-image-crop-picker
react-native-vector-icons
react-navigation
But now Whatever new Package/Library I am Installing in my existing app, some of my existing packages/files are getting removed, and because of it So many errors are coming. why is this happening while installing any of the new package.
Here is screenshot I am attaching when installing new library
package.json
{
"name": "myApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.3",
"react-native-star-rating": "^1.0.9"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}

Resources