41

I have created a new project called auth using react-native init auth at terminal.When i tried to run the project using react-native run-ios. The build failed and gave a error 'React/RCTBridgeDelegate.h' file not found.

Tried to update the react native version

react-native run-ios at terminal in mac

I expect the build to be successful and see the ios simulator The actual result which i got is build failed and hence cant see the simulator

Saranya
  • 595
  • 2
  • 7
  • 19

14 Answers14

57

The issue is related to cocoapods dependency manager. Do the following to fix this:

  1. Open the terminal and go to your project ios directory
  2. Type in pod init (If it doesn't exist) and then pod install
  3. Open the workspace project and delete the build from ios folder
  4. Run react-native run-ios from terminal.

It should work now.

VecopWall
  • 549
  • 1
  • 7
  • 23
Vahid
  • 1,258
  • 1
  • 14
  • 14
  • 1
    There is already podfile existing.when i try to run pod init, it says /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby: bad interpreter: No such file or directory – Saranya Jul 07 '19 at 06:13
  • 1
    if already exist ignore pod init and just type "pod install" and it will take time to be finished, please don't forget to delete the build file from ios folder and then type react-native run-ios – Vahid Jul 07 '19 at 06:20
  • 1
    did you type "pod install" ? It will overwrite the current one – Vahid Jul 07 '19 at 09:26
  • @Vahid I have removed build folder and run pod install and try to build app. But it failed with the same error React/RCTBridgeDelegate.h' file not found in AppDelegate.h file – sejn Dec 02 '19 at 06:29
  • 3
    @sejn I have same issue, have you found any solution? – Parth Mehta Feb 28 '20 at 06:40
  • When I tried pod install I received that: `[!] Invalid `Podfile` file: cannot load such file -- /Users/rafael/workspace/everest-client-app/node_modules/@react-native-community/cli-platform-ios/native_modules.` – rafasalo May 27 '20 at 02:11
  • 1
    does not work at all, just tried on a fresh react-native project to add @react-navigation/native @react-navigation/native-stack non of the steps do help – Macilias Sep 28 '21 at 19:18
  • In the `ios` dir, running `pod deintegrate && pod setup && pod install` (using Rosetta-mode iTerm2 for M1) usually fixes pod issues for me. This time, it did not. – Mike S. Apr 04 '22 at 14:29
  • I our case we've get same error in two Macs with M1 cpu, and the solution to run the App was through Xcode going to Product, Destination, Destination Architecture and choose Show Rosetta destination. After that, the error stay but the App start running in emulator. – Sebastian Diaz Jul 26 '23 at 19:19
13

In my case the libPods-FOO.a library had somehow become unlinked when I did a pod update && pod install. To see if this applies to you:

  1. In Xcode, check under Project Navigator:

    [Your Project Name] --> Targets --> [Your target name] --> General
    
  2. Scroll down to Frameworks, Libraries and Embedded Content

  3. If you don't have a libPods-XXXX.a in there (where XXXX is your project name) then add it:

    1. Click the '+' sign to add the libPods library
    2. Search for libPods in the search box
    3. Choose the libPods-XXXX.a and click Add.

Add library

libPods.....a

cobberboy
  • 5,598
  • 2
  • 25
  • 22
8

Just a hint: for those of you using the M1 Macs, pod install won't work. You should use arch -x86_64 pod install as stated in this issue

Marco Galindo
  • 81
  • 1
  • 1
  • 1
    My understanding is if you set your terminal app to use Rosetta mode, then `arch` is not needed. – Mike S. Apr 04 '22 at 14:32
6

The issue happened due to the missing of React schema in cocoapods dependency. to resolve follow these steps:

  1. open project in XCode using ios/{project name}.xcworkspace file

  2. From menu bar -> click Product-> Scheme -> Manage Scheme

  3. It will open a modal -> click on the + button

  4. List item

  5. New modal -> In target DropDown select React and click okay

  6. close the modal and rebuild project Project - Build

it will resolve the issue.

Arun sankar S
  • 141
  • 1
  • 3
5

In case you have Mac with an Apple M1 chip, It can be resolve in two ways,

#SOLUTION 1

  1. Open Application->Utilites->Terminal.app
  2. Right-click, Terminal.app -> Get Info -> General-> Enable "Open using Rosetta"
  3. Restart Terminal

enter image description here

#SOLUTION 2

  1. From terminal execute

sudo arch -x86_64 gem install ffi

  1. Go to iOS directory and execute

arch -x86_64 pod install

SaRaVaNaN DM
  • 4,390
  • 4
  • 22
  • 30
  • In my case, this did not resolve the issue. I set both Xcode 13.3 and terminal to Rosetta mode. Xcode build fails regardless. I'm not 100% sure, yet, if my issue relates to this. Something else could be breaking that makes this error appear. Still investigating. – Mike S. Apr 04 '22 at 14:35
2

I did what @Vahid suggested, but I also had another issue. A set of instructions I was following told me to pull the related .xcodeproj file into my actual project and then manually link a few different files.

These steps were not necessary and were creating the issue for me.

I was following this: https://github.com/frostney/react-native-ibeacon

But it's better to use this npm package and follow their instructions: https://www.npmjs.com/package/react-native-ibeacons

a_lovelace
  • 490
  • 4
  • 11
2

In my Xcode project I had to have multiple targets.

enter image description here

I added the (dev) target for development purposes, but in order to add React Native to that target you have to add it to the Podfile.

target 'MyApp' do
  config = use_native_modules!

...

  target 'MyAppTests' do
    inherit! :complete
    # Pods for testing
  end

  #  Add your target in the Podfile
  target 'MyApp (dev)' do
    inherit! :complete
  end

...

Then run pod install inside your ios folder, and done!

My setup:

react-native 0.70, macOS Monterey, MacBook Pro M1 2021

Crazyrems
  • 2,551
  • 22
  • 40
1

follow this steps :

  1. Select your project on Xcode

  2. Go to Build Settings

  3. In Search path tab select Header Search Path and add this values for both debug and release

    $(inherited)

    ${PODS_ROOT}

    ${SRCROOT}/../../../ios/Pods/Headers (Make sure to set it to recursive)

enter image description here

abdelhedi hlel
  • 2,903
  • 1
  • 16
  • 20
  • Thank you ! I switched from intel to M2 and my build was failing because the Header Search Path was empty – Alix Humbert Jun 18 '23 at 10:28
  • Edit: Don't use recursive as it may cause other build issues, see: https://stackoverflow.com/questions/75930323/boost-library-compiler-errors-in-xcode – Alix Humbert Jun 18 '23 at 10:53
1

It can happen if you are using mac on M1 chip and trying to run the app on a simulator. Try to install iterm2 from official site(https://iterm2.com/), and launch it with Rosetta(Applications -> Right click on 'Iterm2' app -> "Get info" -> Check "Open using Rosetta"). Then run:

  1. sudo gem install cocoapods
  2. rm -rf /Users/{USERNAME}/.cocoapods/repos/cocoapods
  3. Go to your project folder and run cd ./ios && pod install
  4. Run build with npx react-native run-ios
Kirill Kohan
  • 181
  • 1
  • 2
  • 5
1

In this particular project, certain targets were not working. I noticed the broken targets with this error were missing libPods-myProjectName.a. Under Targets -> General tab, "Frameworks, Libraries and Embedded Content" I pressed the "+" icon and searched for "pods" and added "pods-myProjectName.a" and now it seems to work. This might not be applicable to you, but I am adding this as another possibility of what might be wrong.

Karatekid430
  • 940
  • 11
  • 25
1

The simple pod install command did not work for me. If you have M1 Mac then try using.

arch -x86_64 pod install 
Muhammad Haidar
  • 1,541
  • 16
  • 17
0

[Mac OSX] I updated the cocoapods version brew upgrade cocoapods

Laurent
  • 662
  • 2
  • 10
  • 13
0

For me adding arm64 to Excluded Architectures section works.

enter image description here

efkan
  • 12,991
  • 6
  • 73
  • 106
0

To those who are facing, make sure

  target 'runner' do
    inherit! :complete
    # Pods for production
  end
  target 'runnerDev' do
    inherit! :complete
    # Pods for development
  end

this is present for every flavor in Podfile

Paras Rai
  • 122
  • 1
  • 6