react-native: RCTConvert.h yoga/Yoga.h file not found

I am logging this as a bug as it seems like a bunch of people have logged it as an issue on Stackoverflow … but seems to be a bug http://stackoverflow.com/questions/41505616/yoga-yoga-h-header-file-not-found-after-react-native-integration-in-the-existing

Upgraded to latest react-native 0.4.0

Build project for iOS on Xcode and you get the error message: /Users/adamginsburg/Documents/development/buzzy9/node_modules/react-native/React/Base/RCTConvert.h:13:9: 'yoga/Yoga.h' file not found

  • React Native version: 0.4.0
  • Platform: iOS
  • Operating System: The build issue happen on XCode 8

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 45
  • Comments: 88 (22 by maintainers)

Commits related to this issue

Most upvoted comments

This solution probably won’t work for everyone but when I commented out use_frameworks! in my pod file, the yoga/Yoga.h file not found error went away.

@kmuralidharan91 You don’t need all the above fixes anymore, remove your patch function in your Podfile, remove the postinstall script in your package.json, just put react-native’s v0.42.0-rc.3 tag or master branch in your dependencies and add yoga as a pod dependency and it should work

package.json:

"react-native": "facebook/react-native#master"

Podfile:

  react_path = '../node_modules/react-native'
  yoga_path = File.join(react_path, 'ReactCommon/yoga')

  pod 'React', :path => react_path, :subspecs => [
    'Core',
    'RCTText',
    'RCTImage',
    'RCTWebSocket', # needed for debugging
    'RCTNetwork'
  ]
  pod 'Yoga', :path => yoga_path

Don’t forget to change all your #include "RCT..." to #include <React/RCT...> too

I got the yoga error to go away by adding it to my header search paths

screen shot 2017-02-03 at 9 05 47 pm

I’m getting similar error messages. In my case:

  • ‘React/RCTConvert.h’ file not found in RCTResizeMode.h
  • ‘React/RCTLog.h’ file not found in RCTNetworkTask.m

I had like 5-6 more but those went away after I deleted my node_modules folders and ran npm install. These 2 remained, though, and my app won’t build.

What are we missing?

@julienfouilhe I have the example. SwiftReactNative.zip

the steps is

npm install
pod install
xcodebuild -configuration Debug -scheme "SwiftReactNative" -workspace SwiftReactNative.xcworkspace | xcpretty

and it show

SwiftReactNative/node_modules/react-native/React/Modules/RCTDevMenu.mm:16:9: 'jschelpers/JavaScriptCore.h' file not found

#import <jschelpers/JavaScriptCore.h>
  ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I found the way to fixed my issue: my cocoapods was too old (1.1.1). I just updated my cocoapods to version 1.2.0, and there is no problems any more

@javache @mmmulani Got a PR for this up #12089

After resolving the RCTConvert.h yoga/Yoga.h file not found, I’m now seeing jschelpers/JavaScriptCore.h' file not found. Anyone come across this?

/Users/petar/dev/demo_app/node_modules/react-native/React/Executors/RCTJSCErrorHandling.mm:12:9: 'jschelpers/JavaScriptCore.h' file not found

Using react-native version 0.42.0-rc.3 with Xcode 8.2.1.

After a bit of hacking around, this is now working for me in RN 0.40:

# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!

target 'FrameworkDemo' do
    pod 'React', :subspecs => ['Core'], :path => './node_modules/react-native'
end

pre_install do |installer|
    # Yoga exists in two places in the RN source tree. Delete the obsolete one to avoid redefinitions
    `rm -rf node_modules/react-native/React/CSSLayout`
end

post_install do |installer|
    patch_subspecs(installer)
end

def patch_subspecs(installer)
    # patch source and header files
    `find node_modules/react-native/React node_modules/react-native/ReactCommon \\( -name *.h -o -name *.m -o -name *.mm \\) -print0 | xargs -0 sed -i '' -E 's:<(yoga|jschelpers|cxxreact)/(.*)>:"\\2":g'`

    # exclude duplicate symbols
    # https://github.com/facebook/react-native/issues/11502
    installer.pods_project.targets.each do |target|
        next unless target.name == 'React'

        source_files = target.source_build_phase.files
        uniqs = source_files.uniq { |f| f.file_ref.path }
        (source_files - uniqs).each { |dup| source_files.delete(dup) }
    end
end

Credit to @notjosh at https://github.com/facebook/react-native/issues/11272#issuecomment-268984452 for the original.

Note also since this touches ReactCommon there could be implications for Android or other platforms - untested.

I can confirm updating CocoaPods to 1.2.0 fixed the #import <jschelpers/JavaScriptCore.h> issue on a project here, too.

It’s closed but I still am not sure how to make it work. I do have a Podfile like this pod 'React', :path => './node_modules/react-native', :subspecs => [ 'Core', 'RCTWebSocket', ]

…and did an npm install which upgraded my version of React to 0.41.2

I still get a cstdint file not found Thanks

@rh389 I’m using swift and not using use_frameworks! would be painful, wouldn’t it? Some of my dependencies are written in Swift.

What would need to be done in a post_install script? Changing <yoga/Yoga.h> for "yoga/Yoga.h"did not help, even when I added: ${SRCROOT}/../ios-editor/node_modules/react-native/ReactCommon to the User Header Search Paths of my project

@alloy @rh389 I created a really fast application that displays the compilation error. Hopefully it is just something simple I am doing wrong 😃

https://github.com/joshuafeldman/react-native-missing-file

Be sure to add the Yoga pod to your Podfile as shown here https://github.com/facebook/react-native/pull/12089#issuecomment-277553904

Please never mind… Old node_modules (had to redo npm install).


@julienfouilhe - I replicated the Podfile as well as package.json dependency. Running pod install produces:

Analyzing dependencies Fetching podspec for React from ./node_modules/react-native Fetching podspec for Yoga from ./node_modules/react-native/ReactCommon/yoga [!] No podspec found for Yoga in ./node_modules/react-native/ReactCommon/yoga

Any idea?

I am using react native in an already existing iOS app. Everything is working fine with 0.39.0.

When I tried updating to 0.40.0, I get this error message when compiling (RCTConvert.h yoga/Yoga.h file not found)

@emilsjolander

@alloy there it is 🙌

Appreciate the insight.

@joshuafeldman, @alloy: same problem here.

  • update pod to 1.2.0

  • run “pod update”

  • clean & build

worked for me

@ambientlight:

in my Build Settings ==> Header Search Paths

i used “$(SRCROOT)/Pods/Headers/Public/” - for the environment variable

@alloy yes, I can confirm that with cocoaPods 1.2.0 it builds fine out of the box. thanks.

@alloy What release will this commit be available into? Can we expect it to be part of 0.42.0?

@GrahO23 thanks for trying… ughhh… was hoping for the magical 0.41