react-native: [RN@0.75.2] `yoga/style/Style.h` file not found

Description

Attempting to upgrade my react-native-static-server library from RN@0.74 to RN@0.75.2, building for iOS, new arch, getting the error with yoga: image

Interestingly, I’ve already upgraded a couple of other libs the same way, without having this issue.

Steps to reproduce

Clone https://github.com/birdofpreyru/react-native-static-server/commit/6f6c8993ef0e435577ca9dcbf8560acff9c526ea , try to build the Example App in the library codebase (in the /example folder) for iOS.

React Native Version

0.75.2

Affected Platforms

Runtime - iOS, Build - MacOS

Output of npx react-native info

N/A

Stacktrace or Logs

N/A

Reproducer

N/A

Screenshots and Videos

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (17 by maintainers)

Commits related to this issue

Most upvoted comments

it is also shows at 0.76.1

I had the same issue on RN 0.76.1. Adding this to the Podfile fixed the issue for me.

  # Path to the Yoga headers in Private
  private_yoga_headers = "#{installer.sandbox.root}/Headers/Private/Yoga"
  # Path to the Yoga headers in Public
  public_yoga_headers = "#{installer.sandbox.root}/Headers/Public/Yoga"

  # Copy the Yoga headers from Private to Public
  FileUtils.mkdir_p(public_yoga_headers) unless Dir.exist?(public_yoga_headers)
  system("rsync -a #{private_yoga_headers}/ #{public_yoga_headers}")

Since it needs the installer var, it should be inside the post_install do |installer| block. It worked for me.

post_install do |installer|
    # Path to the Yoga headers in Private
    private_yoga_headers = "#{installer.sandbox.root}/Headers/Private/Yoga"
    # Path to the Yoga headers in Public
    public_yoga_headers = "#{installer.sandbox.root}/Headers/Public/Yoga"

    # Copy the Yoga headers from Private to Public
    FileUtils.mkdir_p(public_yoga_headers) unless Dir.exist?(public_yoga_headers)
    system("rsync -a #{private_yoga_headers}/ #{public_yoga_headers}")


    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false,
       # :ccache_enabled => true
    )
end

@atlj Honestly, I’m not sure. The problem was happening in the original issue because the codegen was generating some stuff for components when there were no actual components in the library. In theory that should not be a problem, but practically it was.

I think you can easily reproduce the issue by following the steps above. In general, I’d say that if a user choose to create a TM, it’s better to set the type to modules. If they chose to build a component, let’s set the type to components.

It’s alway better to have less code to build! 😉

does this mean some of the libraries won’t compile with certain versions of React Native?

We guaranteed Codegen working only for the latest version of React Native as codegen was part of the New Architecture. Now that the new architecture is stable we are going to guarantee that codegen works for versions > 0.76 and in the official support windows. so yeah, technically, yes, libraries depending on older versions of Codegen might not build.

image here you are @cipolleschi