Search code examples
iosswiftreact-nativecocoapods

Macbook Air M2: Invalid RNGestureHandler.podspec Issue Persists Using Cocoapods


Upon running the command pod install inside the IOS folder I seem to be getting the error:

[!] Invalid `Podfile` file: 
[!] Invalid `RNGestureHandler.podspec` file: undefined method `exists?' for File:Class.

 #  from /Users/placeholder/Desktop/placeholder/node_modules/react-native-gesture-handler/RNGestureHandler.podspec:5
 #  -------------------------------------------
 #  
 >  isUserApp = File.exists?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
 #  if isUserApp
 #  -------------------------------------------
.

 #  from /Users/placeholder/Desktop/placeholder/ios/Podfile:14
 #  -------------------------------------------
 #    use_expo_modules!
 >    config = use_native_modules!
 #  

I'm running a Macbook Air with the M2 Chip and Ventura.

Ruby: ruby 2.6.10p210 (2022-04-12 revision 67958) [arm64-darwin22]

Homebrew: 4.1.5

Cocoapods: 1.12.1

Here's what I had also tried

arch -x86_64 pod install

sudo arch -x86_64 gem install ffi

I've also already un- and reinstalled Homebrew and Cocoapods. I've also updated Rosetta, and tried reinstalling Homebrew and Cocoapods using the Terminal in Rosetta mode - didn't work.

Any suggestions would be appreciated as I've been stuck on this issue for multiple hours already.


Solution

  • First remove node_modules, package-lock.json

    Then install newer versions of both libraries

    npm install react-native-gesture-handler@^2.9.0
    npm install react-native-reanimated@^2.14.4
    

    Then run cd ios and pod install.