reactjsreact-nativenpm

Getting Error When Installing Cocoapods in React Native Project


I am working on a React Native Expo project and I am trying to generate the ios files needed for XCode. To do this, I need to run npx pod-install ios after running expo prebuild -p ios to generate the files. However, I keep getting this error below and frankly I am not sure what is going on.

The error is

npx pod-install ios
Scanning for pods...
/Users/frank/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/executable.rb:93: warning: Insecure world writable dir /Users/frank/node_modules/.bin in PATH, mode 040777
1.15.2
> pod install
Using Expo modules
[Expo] Enabling modular headers for pod ExpoModulesCore
[Expo] Enabling modular headers for pod ReactCommon
[Expo] Enabling modular headers for pod EXImageLoader
[Expo] Enabling modular headers for pod SDWebImageWebPCoder
[Expo] Enabling modular headers for pod React-Core
Auto-linking React Native modules for target devicemobileapp: RNCAsyncStorage, RNDeviceInfo, RNGestureHandler, RNReanimated, RNScreens, react-native-safe-area-context, and react-native-webview
Framework build type is static library
[Codegen] Adding script_phases to React-Codegen.
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
[Codegen] Analyzing /Users/frank/Development/Work/Testlio/device-verification-mobile-app-agent/package.json
[Codegen] Searching for codegen-enabled libraries in the app.
[Codegen] The "codegenConfig" field is not defined in package.json. Assuming there is nothing to generate at the app level.
[Codegen] Searching for codegen-enabled libraries in the project dependencies.
[Codegen] Found @react-native-async-storage/async-storage
[Codegen] Found react-native
[Codegen] Found react-native-gesture-handler
[Codegen] Found react-native-reanimated
[Codegen] Found react-native-safe-area-context
[Codegen] Found react-native-screens
[Codegen] Found react-native-webview


[Codegen] >>>>> Searching for codegen-enabled libraries in react-native.config.js
[Codegen] Processing rnasyncstorage
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Supported Apple platforms: ios, macos, tvos, visionos for rnasyncstorage
[Codegen] Processing FBReactNativeSpec
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Processing rncore
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Processing rngesturehandler_codegen
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Supported Apple platforms: ios, macos, tvos, visionos for rngesturehandler_codegen
[Codegen] Processing rnreanimated
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Supported Apple platforms: ios, macos, tvos, visionos for rnreanimated
[Codegen] Processing safeareacontext
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Supported Apple platforms: ios, tvos, visionos for safeareacontext
[Codegen] Processing rnscreens
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Supported Apple platforms: ios, tvos, visionos for rnscreens
[Codegen] Processing RNCWebViewSpec
[Codegen] Searching for podspec in the project dependencies.
[Codegen] Supported Apple platforms: ios, macos for RNCWebViewSpec
[Codegen] Generating Native Code for ios
[Codegen] Generated artifacts: /Users/frank/Development/Work/Testlio/device-verification-mobile-app-agent/ios/build/generated/ios
[Codegen] Generating Native Code for ios
[Codegen] Generated artifacts: /Users/frank/Development/Work/Testlio/device-verification-mobile-app-agent/ios/build/generated/ios
[Codegen] Generating Native Code for ios
[Codegen] Generated artifacts: /Users/frank/Development/Work/Testlio/device-verification-mobile-app-agent/node_modules/react-native/ReactCommon
[Codegen] Generating Native Code for ios
[Codegen] Generated artifacts: /Users/frank/Development/Work/Testlio/device-verification-mobile-app-agent/ios/build/generated/ios
[Codegen] Generating Native Code for ios
[Codegen] Generated artifacts: /Users/frank/Development/Work/Testlio/device-verification-mobile-app-agent/ios/build/generated/ios
[Codegen] Generating Native Code for ios
[Codegen] Generated artifacts: /Users/frank/Development/Work/Testlio/device-verification-mobile-app-agent/ios/build/generated/ios
[Codegen] Generating Native Code for ios
[Codegen] Generated artifacts: /Users/frank/Development/Work/Testlio/device-verification-mobile-app-agent/ios/build/generated/ios
[Codegen] Generating Native Code for ios
[Codegen] Generated artifacts: /Users/frank/Development/Work/Testlio/device-verification-mobile-app-agent/ios/build/generated/ios
[Codegen] Creating component provider.
[Codegen] Generated provider in: /Users/frank/Development/Work/Testlio/device-verification-mobile-app-agent/node_modules/react-native/React/Fabric
[Codegen] Done.
Framework build type is static library
[Codegen] Skipping use_react_native_codegen_discovery.
Analyzing dependencies
Downloading dependencies
Installing EXSplashScreen 0.27.6 (was 0.27.5)
Installing Expo 51.0.35 (was 51.0.21)
Installing ExpoFont 12.0.10 (was 12.0.9)
Installing ExpoHead 3.5.23 (was 3.5.18)
Installing ExpoModulesCore 1.12.24 (was 1.12.19)
Generating Pods project
[!] An error occurred while processing the post-install hook of the Podfile.

[Xcodeproj] Consistency issue: no parent for object Expo.plist: ResourcesBuildPhase, ResourcesBuildPhase

/Users/frank/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/project/object/helpers/groupable_helper.rb:19:in parent'
/Users/frank/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/project/object/build_file.rb:77:in ascii_plist_annotation'

What could be wrong?.

My package.json looks like this


{
  "name": "mobile-app",
  "main": "expo-router/entry",
  "version": "1.0.0",
  "scripts": {
    "start": "expo start",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "test": "jest --detectOpenHandles",
    "lint": "eslint '**/*.{js,jsx,ts,tsx}'",
    "fix": "eslint --fix '**/*.{js,jsx,ts,tsx}'",
    "generate-types": "graphql-codegen --config graphql-codegen.yml",
    "app-clip": "expo run:ios --scheme",
    "pre-build-ios": "expo prebuild -p ios",
    "pre-build-android": "expo prebuild -p android"
  },
  "dependencies": {
    "@apollo/client": "^3.10.8",
    "@expo/vector-icons": "^14.0.3",
    "@react-native-async-storage/async-storage": "^1.24.0",
    "@react-navigation/native": "^6.0.2",
    "crypto-js": "^4.2.0",
    "expo": "~51.0.35",
    "expo-build-properties": "^0.12.5",
    "expo-clipboard": "~6.0.3",
    "expo-constants": "~16.0.2",
    "expo-device": "~6.0.2",
    "expo-font": "~12.0.10",
    "expo-jwt": "^1.8.0",
    "expo-linking": "~6.3.1",
    "expo-router": "~3.5.23",
    "expo-splash-screen": "~0.27.6",
    "expo-status-bar": "~1.12.1",
    "expo-system-ui": "~3.0.7",
    "expo-web-browser": "~13.0.3",
    "graphql": "^15.8.0",
    "jest-expo": "~51.0.4",
    "pod-install": "^0.2.2",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-intl": "^6.6.8",
    "react-native": "0.74.5",
    "react-native-app-clip": "^0.3.1",
    "react-native-device-info": "^11.1.0",
    "react-native-gesture-handler": "~2.16.1",
    "react-native-reanimated": "~3.10.1",
    "react-native-safe-area-context": "4.10.5",
    "react-native-screens": "3.31.1",
    "react-native-web": "~0.19.10",
    "react-native-webview": "13.8.6"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-typescript": "^7.24.7",
    "@graphql-codegen/cli": "4.0.1",
    "@graphql-codegen/introspection": "4.0.0",
    "@graphql-codegen/near-operation-file-preset": "^2.5.0",
    "@graphql-codegen/typescript": "4.0.1",
    "@graphql-codegen/typescript-operations": "4.0.1",
    "@graphql-codegen/typescript-react-apollo": "3.3.7",
    "@graphql-eslint/eslint-plugin": "^3.20.1",
    "@testing-library/jest-native": "^5.4.3",
    "@testing-library/react-native": "^12.5.1",
    "@types/crypto-js": "^4.2.2",
    "@types/jest": "^29.5.12",
    "@types/jsonwebtoken": "^9.0.7",
    "@types/node": "^20.14.11",
    "@types/react": "~18.2.45",
    "@types/react-native": "^0.73.0",
    "@types/react-test-renderer": "^18.0.7",
    "eslint": "^8.57.1",
    "eslint-config-airbnb": "^19.0.4",
    "eslint-config-expo": "^7.0.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "eslint-plugin-react": "^7.36.1",
    "eslint-plugin-react-native": "^4.1.0",
    "jest": "^29.2.1",
    "jest-expo": "~51.0.3",
    "prettier": "^3.3.3",
    "react-test-renderer": "18.2.0",
    "typescript": "~5.3.3"
  },
  "private": true
}

I have tried deleting all node packages and reinstalling but that does not seem to work. I have also tried switching to yarn but the issues still persists


Solution

  • It seems the issue you are facing is related to the the architecture of your machine.

    Going through the error message you posted, it seems that you are using a Macbook and most likely using one that runs on Mx (i.e M1 or M2, e.t.c).

    The problem is that CocoaPods only works on intel architecture and you are trying to install it on an architecture that does not work (You are trying to install it on Mx).

    So basically you need to install the package on intel architecture and not on Mx

    To do this you need to:

    1. Open a new terminal in VSCode
    2. Enter this command intel="env /usr/bin/arch -x86_64 /bin/zsh --login", this sets the architecture to intel
    3. Run npx pod-install ios again

    This should fix the issue