native-bridge.jsError: ENOENT: no such file or directory

I’ve been trying to instal capacitor 3.0, but I keep running into this error whenever I try to rund npx cap add ios:

Error: ENOENT: no such file or directory, lstat ‘/Users/erick/Documents/Code/spin/node_modules/@capacitor/core/native-bridge.js’

Once it fails here, the ios folder does not contain the necessary files to run, so CocoaPods fails.

I can’t find any info on how to fix this.

You need to update all capacitor packages to 3.0.0, looks like you have not updated @capacitor/cli

Just did that and verified it. Getting the same error. Is there anything else that needs to be updated? I’m pretty much stuck in the water at this point.

Did you upgrade @capacitor/ios to v3 as well?

Yes. Here’s the package.json

{
  "name": "spin",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "@capacitor/core": "^3.0.0",
    "@capacitor/ios": "^3.0.0",
    "@ionic/react": "^5.5.0",
    "@ionic/react-router": "^5.5.0",
    "@solana/web3.js": "^1.12.0",
    "@testing-library/jest-dom": "^5.11.9",
    "@testing-library/react": "^11.2.5",
    "@testing-library/user-event": "^12.6.3",
    "@types/jest": "^26.0.20",
    "@types/node": "^12.19.15",
    "@types/react": "^16.14.3",
    "@types/react-dom": "^16.9.10",
    "@types/react-router": "^5.1.11",
    "@types/react-router-dom": "^5.1.7",
    "ionicons": "^5.4.0",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.2",
    "typescript": "^4.1.3",
    "web-vitals": "^0.2.4",
    "workbox-background-sync": "^5.1.4",
    "workbox-broadcast-update": "^5.1.4",
    "workbox-cacheable-response": "^5.1.4",
    "workbox-core": "^5.1.4",
    "workbox-expiration": "^5.1.4",
    "workbox-google-analytics": "^5.1.4",
    "workbox-navigation-preload": "^5.1.4",
    "workbox-precaching": "^5.1.4",
    "workbox-range-requests": "^5.1.4",
    "workbox-routing": "^5.1.4",
    "workbox-strategies": "^5.1.4",
    "workbox-streams": "^5.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@capacitor/cli": "^2.4.7"
  },
  "description": "An Ionic project"
}

I’m also getting a cocao pods install error after that. I’m not sure if they’re related, or if the second error is the critical one.

ℹ Installing iOS dependencies – Skipping: already installed
✔ Adding native xcode project in: /Users/erick/Documents/Code/spin/ios in 12.17ms
✔ add in 12.73ms
✔ Copying web assets from build to ios/App/public in 56.57ms
✖ Copying native bridge: ENOENT: no such file or directory, lstat '/Users/erick/Documents/Code/spin/node_modules/@capacitor/core/native-bridge.js'
✖ copy: ENOENT: no such file or directory, lstat '/Users/erick/Documents/Code/spin/node_modules/@capacitor/core/native-bridge.js'
[error] [Error: ENOENT: no such file or directory, lstat '/Users/erick/Documents/Code/spin/node_modules/@capacitor/core/native-bridge.js'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'lstat',
  path: '/Users/erick/Documents/Code/spin/node_modules/@capacitor/core/native-bridge.js'
}
✔ Updating iOS plugins in 19.85ms
  Found 0 Capacitor plugins for ios:
✖ Updating iOS native dependencies with "pod install" (may take several minutes): 

....
LoadError - dlopen(/opt/homebrew/lib/ruby/gems/3.0.0/gems/ffi-1.15.0/lib/ffi_c.bundle, 9): no suitable image found.  Did find:
        /opt/homebrew/lib/ruby/gems/3.0.0/gems/ffi-1.15.0/lib/ffi_c.bundle: mach-o, but wrong architecture
        /opt/homebrew/lib/ruby/gems/3.0.0/gems/ffi-1.15.0/lib/ffi_c.bundle: mach-o, but wrong architecture

I uninstalled/reinstalled everything having to do with @capaitor, and was able to move past the bridge errors. Now I’m still have cocoapod install issues

spin % ionic capacitor run ios -l --external
? Which device would you like to target? iPhone 12 Pro (simulator) (962410A4-D3D
5-4BBE-A97A-C1FC877B375C)
> capacitor sync ios
[capacitor] [warn] Using the iOS project root for the public directory is deprecated.
[capacitor]        Please follow the Upgrade Guide to move public inside the iOS target directory: https://capacitorjs.com/docs/v3/updating/3-0#move-public-into-the-ios-target-directory
[capacitor] ✔ Copying web assets from build to ios/App/public in 68.08ms
[capacitor] ✔ Creating capacitor.config.json in ios/App/App in 534.21μp
[capacitor] ✔ copy ios in 73.00ms
[capacitor] ✔ Updating iOS plugins in 218.50μp
[capacitor] ✖ Updating iOS native dependencies with pod install - failed!
[capacitor] ✖ update ios - failed!
[capacitor] [error] Analyzing dependencies
[capacitor]         Searching for inspections failed: undefined method `map' for nil:NilClass

I have reinstalled cocoapods from brew and have been searching for other help, but still nothing. Anything help would be appreciated!

Getting closer. BTW I’m on a M1 Mac Mini
Steps:

  1. Upgraded Big Sur to 11.3.1
  2. Uninstalled Homebrew
  3. Unchecked Run in Rosetta for terminal.app
  4. Installed Homebrew (this installs the M1 version)
  5. Installed Cocopod from home brew
  6. Installed yarn
  7. Ran yarn for the project
  8. Installed @capacitor/code /ios /cli
  9. Installed typescript
  10. Build still failed when I ran ionic capacitor run ios -l --external
  11. Change platform: ios to 14.4.2

I was then able to get the prompts for which simulator and which IP address. Then it fails:

 /Users/erick/Documents/Code/spin/ios/App/App/AppDelegate.swift:2:8: error: compiling for iOS 11.0, but module 'Capacitor' has a minimum deployment target of iOS 12.0: /Users/erick/Documents/Code/spin/ios/DerivedData/962410A4-D3D5-4BBE-A97A-C1FC877B375C/Build/Products/Debug-iphonesimulator/Capacitor/Capacitor.framework/Modules/Capacitor.swiftmodule/arm64-apple-ios-simulator.swiftmodule
[capacitor]         import Capacitor
[capacitor]         ^
[capacitor]         
[capacitor]         ** BUILD FAILED **
[capacitor]         
[capacitor]         
[capacitor]         The following build commands failed:
[capacitor]         CompileSwift normal arm64 /Users/erick/Documents/Code/spin/ios/App/App/AppDelegate.swift
[capacitor]         CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
[capacitor]         (2 failures)
[capacitor]         
[ERROR] An error occurred while running subprocess capacitor.

I have not been able to move past this error.

Okay last two steps!

  1. Update the signing to your team in xCode
  2. Set the min build version to ios 12.1

Bam! Bob’s your uncle!

Yup that sounds about right, the problem always lies with XCode signing :joy:

The upgrade guide mentions the new minimum of iOS 12.0, but it is definitely something I’ve missed before migrating my own apps!