Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCTConvert.h yoga/Yoga.h file not found #11781

Closed
adamgins opened this issue Jan 9, 2017 · 88 comments
Closed

RCTConvert.h yoga/Yoga.h file not found #11781

adamgins opened this issue Jan 9, 2017 · 88 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@adamgins
Copy link

adamgins commented Jan 9, 2017

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
@adamgins
Copy link
Author

adamgins commented Jan 9, 2017

@fgaleano
Copy link

fgaleano commented Jan 9, 2017

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
Copy link

julienfouilhe commented Jan 10, 2017

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

@emilsjolander
Copy link
Contributor

Seems like the xcode project needs to be fixed in some way. Not really sure what could have broken this. @mmmulani Could you have a look?

@JesseARWhite
Copy link

This looks like it has something to do with Cocoapods integration, @julienfouilhe @emilsjolander can you confirm if this is coming from cocoapods or not?

@julienfouilhe
Copy link

julienfouilhe commented Jan 10, 2017

@JesseARWhite I am using CocoaPods yes, but I don't know if it is responsible for the error or not. XCode is giving the error when trying to build the app.

@robhogan
Copy link
Contributor

robhogan commented Jan 10, 2017

I think this is the same issue we had in #9544, and occurs whenever use_frameworks is enabled - essentially a framework can't include its own internal headers using angle brackets.

Because FB needed to use angle brackets for its internal builds of CSS Layout @alloy proposed a compromise which was removed in 7c91f89 . Since the move to using angle brackets everywhere, the use of RN as a framework now looks pretty much beyond repair.

AFAIK it's still possible even in a swift project to disable use_frameworks and import RN via a bridging header. It should also be possible to find+replace imports in post_install, but that's really only a brittle hack if RN has dropped support for frameworks.

@julienfouilhe
Copy link

julienfouilhe commented Jan 10, 2017

@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

@mmmulani
Copy link
Contributor

cc @javache can you reapply for fix for the include header to yoga now?

@mmmulani
Copy link
Contributor

hey everyone, I tried to repro this issue by creating a tiny project and following the Obj-C guide here: https://facebook.github.io/react-native/docs/integration-with-existing-apps.html
but I was not able to run into the Yoga build problem.

does anyone have a smaller repro case they could post?

@robhogan
Copy link
Contributor

robhogan commented Jan 10, 2017

I'll see if I can post a repro case tomorrow, I did reproduce the issue earlier - in the meantime have you tried enabling use_frameworks, even in Objective-C? I haven't yet been able to get that working as a minimal build in a new app at all without modifying RN.

Edit: (Back at the mac) - repro case now up

git clone https://github.com/rh389/rn-framework-demo
cd rn-framework-demo
yarn install
open FrameworkDemo.xcworkspace

That was created simply by creating a new single-page ObjC app with the XCode wizard, then yarn add react-native react, adding a Podfile as in the repo, and pod install.

Attempting to build that in XCode should allow you to reproduce the yoga/Yoga.h not found immediate issue. It is possible to add [...]/ReactCommon recursive to the project's header search paths in order for Yoga.h to be found, but then the issue is eg #import <yoga/Yoga.h>: RCTConvert.h:13:9: Include of non-modular header inside framework module 'React.RCTConvert' - that's the more fundamental problem once you've got beyond search paths - as discussed in #9544 (and as far as I understand it - no expert) framework modules can have dependencies on their own internal headers or on other framework modules, but not on arbitrary, potentially external libraries.

I don't know of a way to overcome this while the #import style is what it is across RN.

@julienfouilhe
Copy link

julienfouilhe commented Jan 11, 2017

Hi @mmmulani I also created a simple swift project, with all the files already in the repo, so all you have to do is launch the xcworkspace in xcode and try to build: https://github.com/julienfouilhe/test-yoga-file-not-found

Thanks!

What is weird too is the directories architecture:
screen shot 2017-01-11 at 1 36 18 pm

@mmmulani
Copy link
Contributor

@javache and I found a workaround to this problem and we'd like someone from the community to champion it and support it going forward.

we created a yoga.podspec at node_modules/react-native/ReactCommon/yoga with contents:

Pod::Spec.new do |s|
  s.name                = "yoga"
  s.source_files = '**/*.{c,h}'
  s.header_dir   = 'yoga'
  s.platform            = :ios, "8.0"
  s.author = ''
  s.license = 'a'
  s.homepage = 'a'
  s.source = { :path => '.' }
  s.summary = 'a'
  s.version = '0.1'
end

and then include it from the main Podfile with pod 'yoga', :path => './node_modules/react-native/ReactCommon/yoga'

you would have to make another one for jschelpers and possibly any other subspec we have that uses a different header search path.

but this seems like a bug in CocoaPods, it should let use create the React dependency and link all its subspecs statically but create the whole React dependency as a dylib. cc @alloy for any ideas here

@Aleksandern
Copy link

Aleksandern commented Jan 20, 2017

@mmmulani
It looks like it doesn't work in my case
I still have have an error

RCTConvert.h:13:9: fatal error: 'yoga/Yoga.h' file not found
#import <yoga/Yoga.h>

Podfile

platform :ios, '8.0'
use_frameworks!

target 'app' do
pod 'React', path: '../node_modules/react-native', :subspecs => [
'Core',
'RCTActionSheet',
'RCTAnimation',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket'
]
`pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
end

But I had to change pod 'yoga', :path => './node_modules/react-native/ReactCommon/yoga' to pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

"react": "15.4.2",
"react-native": "0.40.0",

@cparjaszewski
Copy link

Having the same issue, any progress on this?

@ghuh
Copy link

ghuh commented Jan 23, 2017

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.

@yimingtang
Copy link

yimingtang commented Jan 24, 2017

I'm making a private pod. The podspec file of version 0.40.0 fails CocoaPods lint command. It shows the 'yoga/Yoga.h' file not found error from the compiler.

It's a sad story that I came accross a similar error in version 0.36.0 when I tried to integrate React Native into my existing app with CocoaPods. Now, the issue appears again.

NOTE: Commenting out use_frameworks! works. However, after pod install, thousands lines of warnings are shown in the console: [!] [Xcodeproj] Generated duplicate UUIDs:, even on a brand new Xcode project.

Did you seriously lint your podspec before a new release?

@Gagege
Copy link

Gagege commented Jan 24, 2017

Is there a solution where I don't have to comment out use_frameworks!? I'd really rather not, since I'm using React Native in an existing Swift project.

@renatomcamilio
Copy link

@Gagege I'm not sure I can call it a solution, but I'd say it's palliative at the very least: I've downgraded to 0.39.2; Then you'll probably need the same fixes that I had to do for CSSLayout, since you also need use_frameworks!: #11272 (comment)

@guysegal
Copy link

does this post install script repair the yoga problem? (by changing CSSLayout to Yoga)

@robhogan
Copy link
Contributor

robhogan commented Jan 26, 2017

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 #11272 (comment) for the original.

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

@alloy
Copy link
Contributor

alloy commented Jan 26, 2017

@javache @mmmulani Just getting back on RN work from a hiatus. I fixed a podspec in the yoga repo yesterday, thinking it was somehow related to this, but am now thinking that it is not: facebook/yoga#352

In this other comment @javache mentions “we've split the react-native podspec into multiple podspecs”, is that available somewhere?

Basically, what is the latest that I should be looking at and work from?

@JulianKingman
Copy link

I'm not using cocoapods and have the same issue. @adamgins, did you find a fix?

Related stack overflow question: http://stackoverflow.com/questions/31860715/rct-linking-manager-file-not-found

@adamgins
Copy link
Author

@JulianKingman no, I downgraded to 0.39.2 and have been on vacation for the last week... so need to get back to this now.

@alloy
Copy link
Contributor

alloy commented Jan 27, 2017

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

@adamgins
Copy link
Author

@alloy thanks heaps... I have not tried this yet. Also wondering if anyone had seen any improvements with 0.4.0 https://github.com/facebook/react-native/releases/tag/v0.41.0-rc.0 ?

@joshuafeldman
Copy link

@rh389 we have been using this setup for over a year without issue. The issue only came up when upgrading to 0.42.0. All the correct files exist at the correct spot. pod install succeeds without any issues.

Essentially we checkin the contents of react-native to Other Sources/ReactNative so other iOS engineers not working with React do not have to install node to run the project.

@alloy
Copy link
Contributor

alloy commented Mar 14, 2017

@joshuafeldman Can you share a reduced example app that demonstrates the problem?

@joshuafeldman
Copy link

@alloy I will try and find some time this morning and wrap something up

@joshuafeldman
Copy link

@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

@ambientlight
Copy link

@joshuafeldman, @alloy:
Run into the same thing.

Went into the Pods.xcodeproj within Xcode. Then opened React target Build Settings. Looked into Header Search Paths, $(PODS_TARGET_SRCROOT) environment variable doesn't get resolved. (cocoapods issue?)
So replacing it with the full absolute path to react-native essentially resolves this issue at the project builds fine.

Steps to reproduce (cocoapods version 1.1.1):

  1. Create a new folder with ios and js folders inside.
  2. Create a new swift iOS project and place it into ios.
  3. In js create a package.json with following content:
{
  "name": "test",
  "version": "1.0.0",
  "private": true,
  "description": "Test",
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "react": "~15.4.2",
    "react-native": "~0.42.0"
  }
}
  1. npm install (in js)
  2. in iOS create Podfile with this content:
platform :ios, '8.0'
inhibit_all_warnings!
use_frameworks!

target 'Test'
pod 'Yoga', :path => '../js/node_modules/react-native/ReactCommon/yoga'
pod 'React', :path => '../js/node_modules/react-native', :subspecs => [
  'Core',
  'RCTImage',
  'RCTNetwork',
  'RCTText',
  'RCTWebSocket',
]
  1. pod install (in iOS) goes fine.
  2. open workspace -> build -> same issue as @joshuafeldman

@alloy
Copy link
Contributor

alloy commented Mar 16, 2017

@ambientlight You need CocoaPods version >= 1.2.0. Can you double-check if that fixes it for you?

@alloy
Copy link
Contributor

alloy commented Mar 16, 2017

@joshuafeldman Awesome, thanks! Will take a look later today.

@ambientlight
Copy link

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

@Elik86
Copy link

Elik86 commented Mar 16, 2017

@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

@joshuafeldman
Copy link

@alloy the project I linked to was setup using cocoapods version 1.2.0 and exhibits the issue. I wonder what the difference is.

@alloy
Copy link
Contributor

alloy commented Mar 16, 2017

@joshuafeldman I gave it a spin, the issue is the space in the ./Other Sources path. This is definitely a bug in the podspec.

I’ll make a PR for this, but in the meantime you can work around it by either:

  • Removing the whitespace from Other Sources
  • Patch Other Sources/ReactNative/React.podspec to replace "$(PODS_TARGET_SRCROOT)/ReactCommon" with "\"$(PODS_TARGET_SRCROOT)/ReactCommon\""

@joshuafeldman
Copy link

@alloy there it is 🙌

Appreciate the insight.

facebook-github-bot pushed a commit that referenced this issue Mar 18, 2017
Summary:
* Fixes issue where headers could not be found due to whitespace in an unquoted header search path. #11781 (comment)
* Stabilises CI but not needing to download the source for Yoga, but use the existing cloned repo instead.

/cc mkonicek
Closes #13007

Differential Revision: D4735347

fbshipit-source-id: 933aefcb0e65537d2e759d25f4e3b81cdf4b8cb5
maarf pushed a commit to fullcontact/react-native that referenced this issue Apr 26, 2017
Summary:
Fixes facebook#11272
Fixes facebook#11572
Fixes facebook#11781

The main changes here are:

* This depends on the latest CocoaPods (1.2.0). It’s currently in RC, but if I’m not mistaken a proper release is expected soon. /cc dantoml
* Adds required header search paths for the jschelpers and cxxreact subspecs.
* Makes the jschelpers and cxxreact headers private to building React Native, not visible to the user’s project.
* It uses the canonical upstream Yoga v1.0.0 podspec: https://github.com/facebook/yoga/blob/master/Yoga.podspec
* Consistent styling.

I have been able to get our app to build again using this artsy/emission#437. The spec has some warnings, but otherwise fully passes lint.

rh389 sjmueller Could you please test with your projects?
Closes facebook#12089

Differential Revision: D4518605

fbshipit-source-id: ecf86232d8b1af52d139eadd1acc10f5c1d42c29
@gotoAndBliss
Copy link

This error occurs again on a fresh install of react-native: 0.44.0

@quantuminformation
Copy link
Contributor

@gotoAndBliss try deleting your ios build folder

@cliren
Copy link

cliren commented Jun 12, 2017

I am running into the following error and have setup a simple example for anyone to advise what's going wrong here: https://github.com/cliren/RNIntegration.

Using cocopods version: 1.1.1 (can't upgrade due to exiting app's dependency). Appreciate any help!

RNIntegration/js/node_modules/react-native/React/Modules/RCTDevSettings.mm:16:9: fatal error: 'jschelpers/JavaScriptCore.h' file not found
#import <jschelpers/JavaScriptCore.h>
        ^
1 error generated.

@tmaly1980
Copy link

tmaly1980 commented Jun 13, 2017

I had a similar issue with yoga/Yoga.c, and fixed it by running react-native link

@cliren
Copy link

cliren commented Jun 13, 2017

@tmaly1980 I tried your suggestion on https://github.com/cliren/RNIntegration but still ran into the same issue. I am using the below dependencies, may I know what versions are you using?

"react": "16.0.0-alpha.12",
"react-native": "0.45.1"

@tmaly1980
Copy link

tmaly1980 commented Jun 13, 2017 via email

@cliren
Copy link

cliren commented Jun 14, 2017

@tmaly1980 I tried 0.42.3 and 15.4.1 but still get the same error. It looks very fragile unless I am missing something basic. Would you mind checking if I am missing anything here: https://github.com/cliren/RNIntegration?

react-native-cli: 2.0.1
react-native: 0.42.3

@tmaly1980
Copy link

tmaly1980 commented Jun 14, 2017 via email

@samthui
Copy link

samthui commented Sep 11, 2017

After upgrading from RN 0.42.3 to 0.43.3, I got similar issue with RCTDevMenu, though I'm sure these file exist.
My project also uses CocoaPods for iOS project. After re-running pod install and restart MAC, it works normally.
I noticed that in terminal console of pod install, it logged:

Installing React 0.43.3 (was 0.42.3)
Installing Yoga 0.43.3.React (was 0.42.3.React)

(Thanks to that I know that CocoaPods need to re-config RN dependency by running pod install, previously I thought that CocoaPods only needs to be configured once and use path to its dependencies all afterwards.)

@brenordr
Copy link

For the ones having this issue with RN 0.47 or above,
I've discovered that it appear in a project I'm working after change the disk to case sensitive.
CocoaPods seems name the Yoga project as <Yoga/Yoga.h> not <yoga/Yoga.h>

Revert the disk fixed (at least locally) the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

Successfully merging a pull request may close this issue.