score:167

Accepted answer

in my case this particular problem happened when i was trying to archive a 0.40+ react-native app for ios (solution was found here: reliable build on ^0.39.2 fails when upgrading to ^0.40.0).

what happened was that xcode was trying to build the react-native libraries in parallel and was building libraries with implicit react dependencies before actually building the react library.

the solution in my case was to:

  1. disable the parallel builds:

    • xcode menu -> product -> scheme -> manage shemes...
    • double click on your application
    • build tab -> uncheck parallelize build
  2. add react as a project dependecy

    • xcode project navigator -> drag react.xcodeproj from libraries to root tree
    • build phases tab -> target dependencies -> + -> add react

score:-3

what you can do to get it right is:

1) npm uninstall reat-native-fs to uninstall library

2)npm unlink react-native-fs to unlink the library

now the library is successfully removed and now install the lib again in your project and this time link everything manually. sometime automatic linking causes this error.

score:0

if you want to make it from your editor also open smobile.xcscheme

and change parallelizebuildables = "no"

score:0

for me didn't work any from the above solutions and below it is what worked (i had already checked out parallelize build and added react)

1. open xcode --> to libraries add `$librarywhichdoesnotwork.xcodeproj$`
2. then for your app in the `build phases` add to the `link binary with libraries` the file `lib$librarywhichdoesnotwork$.a`

score:0

i've encountered this issue while upgrading from 0.58.4 to new react-native version 0.60.4. nothing from what i found on the internet helped me, but i managed to get it working:

go to build settings, search for 'header search paths', select the entry, press delete button.

i had these values overriden, and looks like they fell back to defaults after deletion. also cocoapods was complaining about it with messages in terminal after pod install:

[!] the `app [release]` target overrides the `header_search_paths` build setting defined in `pods/target support files/pods-app/pods-app.release.xcconfig'. this can lead to problems with the cocoapods installation

score:0

if you want to keep parallelise build enabled and avoid the missing header problems, then provide a pre-build step in your scheme to put the react headers into the derived-data area. notice the build settings are coming from the react project in this case. yes it's not a thing of beauty but it gets the job done and also shaves a lot of time off the builds. the prebuild step output ends up in prebuild.log. the exact headers you'll need to copy over will depend on your project react-native dependencies, but you'll get the jist from this.

edit scheme => build

get the derived data directory from the environment variables and copy the required react headers over.

#build_prestep.sh (chmod a+x)
derived_root=$(echo $shared_derived_file_dir|sed 's/derivedsources//1')
react_base_headers=$(echo $project_file_path|sed 's#react.xcodeproj#base/#1')
react_view_headers=$(echo $project_file_path|sed 's#react.xcodeproj#views/#1')
react_modules_head=$(echo $project_file_path|sed 's#react.xcodeproj#modules/#1')
react_netw_headers=$(echo $project_file_path|sed 's#react/react.xcodeproj#libraries/network/#1')
react_image_header=$(echo $project_file_path|sed 's#react/react.xcodeproj#libraries/image/#1')

echo derived root = ${derived_root}
echo react headers = ${react_base_headers}

mkdir -p ${derived_root}include/react/

find  "${react_base_headers}" -type f -iname "*.h" -exec cp {} "${derived_root}include/react/" \;
find  "${react_view_headers}" -type f -iname "*.h" -exec cp {} "${derived_root}include/react/" \;
find  "${react_modules_head}" -type f -iname "*.h" -exec cp {} "${derived_root}include/react/" \;
find  "${react_netw_headers}" -type f -iname "*.h" -exec cp {} "${derived_root}include/react/" \;
find  "${react_image_header}" -type f -iname "*.h" -exec cp {} "${derived_root}include/react/" \;

the script does get invoked during a build-clean - which is not ideal. in my case there is one env variable which changes letting me exit the script early during a clean.

if [ "$run_clang_static_analyzer" != "no" ] ; then
    exit 0 
fi

score:1

this error appeared for me after i ran pod install command for the new dependencies. along with those, react had also been installed. therefore probably xcode was confused for path. i removed these lines from podfile and error was gone. please note that those removed from here were already linked in xcode.

target 'app' do

  pod 'googlemaps'
  pod 'firebase/auth', '~> 6.3.0'
  pod 'firebase/database', '~> 6.3.0'

  # removed four pods below and it worked.

  pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'

  pod 'reactnativepermissions', :path => '../node_modules/react-native-permissions'

  pod 'react-native-image-resizer', :path => '../node_modules/react-native-image-resizer'

  pod 'rnfs', :path => '../node_modules/react-native-fs'

  end

score:1

go to ios folder in your project and install pod -

$ pod install

if you are getting any error in installation of pod type command-

$ xcode-select -p

result should be - /applications/xcode.app/contents/developer

if the path is incorrect then open your ios project in xcode and go to: xcode->preferences->command line tools-> select xcode

and again install the pod your issue will be fixed.

score:1

i receive this error in any new module i create with create-react-native-module. none of the posted solutions worked for me.

what worked for me was first making sure to run yarn in the newly created module folder in order to create node_modules/ (this step is probably obvious). then, in xcode, select product -> scheme -> react instead of the default selection of mymodulename.

score:1

anhdevit's suggestion in https://github.com/facebook/react-native/issues/24363#issuecomment-488547280 worked for me:

in your terminal, run: defaults delete com.apple.dt.xcode

score:2

latest releases of react-native libraries as explained in previous posts and here have breaking compatibility changes. if you do not plan to upgrade to react-native 0.40+ yet you can force install previous version of the library, for example with react-native-fs:

npm install --save -e react-native-fs@1.5.1

score:2

i was able to build a debug, but i was unable to build an archive.

i solved this issue by dragging react.xcodeproj found in /node_modules/react-native/react to my root directory in xcode, then added react as a target dependancy in build phases > target dependencies.

score:2

after react native 0.60 this issue is often caused by a linked library mixed with the new 'auto-linking' feature. this fixes it for me

unlink old library using

$ react-native unlink react-native-fs

refresh pods integration entirely using

$ pod deintegrate && pod install

now reload your workspace and do a clean build.

score:2

i ran into this issue after doing a manual react-native link of a dependency which didn't support auto link on rn 0.59+

the solution was to select the xcodeproj file under the libraries folder in xcode and then in build settings, change header search paths to add these two (recursive):

$(srcroot)/../../../ios/pods/headers/public/react-core
$(srcroot)/../../../ios/pods/headers/public

score:2

my solution was to remove everything in libraries like described here

score:3

for viewers who got this error after upgrading react native to 0.40+, you may need to run react-native upgrade on the command line.

score:3

if libraries/react.xcodeproj are red in xcode then reinstall node_modules

rm -rf node_modules && yarn

my newly created project from react-native 0.46.3 was red :s i have npm 5.3.0 and yarn 0.24.5 when i did react-native init

score:4

for me, this error occurred when i added a new scheme/target (app.staging) in the app and installed pods using pod install.

this issue is occurring due to pods are not shared for all targets. so i need to add newly added target (app.staging) inside the podfile.

here is my podfile.

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'app' do
  # pods for app
  pod 'fblazyvector', :path => "../node_modules/react-native/libraries/fblazyvector"
  pod 'fbreactnativespec', :path => "../node_modules/react-native/libraries/fbreactnativespec"

  target 'apptests' do
    inherit! :search_paths
    # pods for testing
  end

  # pods for staging app // important line below
  target 'app.staging'

  use_native_modules!
end

score:15

change

  #import "rctbridgemodule.h"

to

 #import "react/rctbridgemodule.h"

score:28

quick fix (not the best)

change the import react-native header lines:

 #import <react/rctbridgemodule.h>
 #import <react/rctlog.h>

to:

 #import "rctbridgemodule.h"
 #import "rctlog.h"

here is an example of changes i had to make for the library i was trying to use: closes #46 - 'rctbridgemodule.h' file not found.

score:36

make sure you disable parallelise build and add react target above your target

enter image description here


Related Query

More Query from same tag