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

[3.16.0] 'worklets/WorkletRuntime/ReanimatedHermesRuntime.h' file not found #6607

Closed
efstathiosntonas opened this issue Oct 17, 2024 · 18 comments · Fixed by #6614
Closed

[3.16.0] 'worklets/WorkletRuntime/ReanimatedHermesRuntime.h' file not found #6607

efstathiosntonas opened this issue Oct 17, 2024 · 18 comments · Fixed by #6614
Labels
Missing repro This issue need minimum repro scenario Platform: iOS This issue is specific to iOS

Comments

@efstathiosntonas
Copy link
Contributor

efstathiosntonas commented Oct 17, 2024

Description

After upgrading from 3.15.5 I get this error on ReanimatedHermesRuntime:

'worklets/WorkletRuntime/ReanimatedHermesRuntime.h' file not found

Tried with no luck:

  1. pod deintegrate
  2. removed derived data
  3. rm -rf node_modules
  4. install everything back

Steps to reproduce

  1. upgrade from 3.15.5
  2. cannot build
  3. xcode 16

Snack or a link to a repository

none

Reanimated version

3.16.0

React Native version

0.75.4

Platforms

iOS

JavaScript runtime

Hermes

Workflow

React Native

Architecture

Paper (Old Architecture)

Build type

Debug app & dev bundle

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Platform: iOS This issue is specific to iOS Missing repro This issue need minimum repro scenario labels Oct 17, 2024
Copy link

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

@efstathiosntonas
Copy link
Contributor Author

efstathiosntonas commented Oct 17, 2024

I believe this is the offending PR:

I use static frameworks on Podfile:

use_frameworks! :linkage => :static

Screenshot 2024-10-17 at 18 38 46

@piaskowyk
Copy link
Member

You are so fast man! 🤯

@efstathiosntonas
Copy link
Contributor Author

efstathiosntonas commented Oct 17, 2024

I believe in you guys and I install new versions the second they come out 🤣 🤣

@tomekzaw
Copy link
Member

Working on it ⌛

@hamdij0maa
Copy link

installed it after 1 min too 🤣

@werlensantos
Copy link

The same problem occurred on mine too. Is there any way to fix this or should I wait for a new fix version?

@tomekzaw
Copy link
Member

tomekzaw commented Oct 18, 2024

@werlensantos Please wait for 3.16.1 early next week

@tomekzaw
Copy link
Member

tomekzaw commented Oct 18, 2024

Here's a fix (more of a workaround): #6614. It also requires changes from #6612. Now I'm waiting for an internal review.

@efstathiosntonas
Copy link
Contributor Author

efstathiosntonas commented Oct 18, 2024

@werlensantos Please wait for 3.16.1 early next week

it will be available on nightly, right? (if #6614 is merged)

thanks @tomekzaw for the quick fixes!

@ethanneff
Copy link

should you remove the 3.16.0 version since it is broken?

@efstathiosntonas
Copy link
Contributor Author

should you remove the 3.16.0 version since it is broken?

I believe that the only projects that are affected are the ones using react-native-firebase so it’s not entirely broken.

github-merge-queue bot pushed a commit that referenced this issue Oct 18, 2024
## Summary

Fixes
#6607.

This is more of a workaround to fix issue with missing headers when
building Reanimated with static linkage for iOS. I spent several hours
on trying to make it right but it would work correctly only partially. I
will post my findings here or internally later on and I hope to find a
better solution sometime in the future.

This workaround adds paths to `Common/cpp` and `apple/` directories to
`HEADER_SEARCH_PATHS` – the preprocessor looks for headers in these
locations. I can't use an absolute path (calculated in Ruby) because it
would make the output setup-dependent and thus affect checksums in
`Podfile.lock` which is unwanted as some apps check against checksum
changes on CI.
 
## Test plan

Tested on fabric-example app with `USE_FRAMEWORKS=static` and without.

---

### My findings

When installing pods in `fabric-example` with `cd ios && bundle install
&& bundle exec pod install`, the headers are visible in `ios/Pods`
directory:

```
$ find . -name "REAUIKit.h"
./Pods/Headers/Public/RNReanimated/reanimated/apple/REAUIKit.h
./Pods/Headers/Private/RNReanimated/reanimated/apple/REAUIKit.h
```

However, after running `USE_FRAMEWORKS=static bundle exec pod install`,
the headers are no longer present:

```
$ find . -name "REAUIKit.h"
<no output>
```

Because of this, `#import <reanimated/apple/REAUIKit.h>` doesn't work,
but when changed back to `#import <RNReanimated/REAUIKit.h>` it works
fine (jump to file also works in Xcode).

This made me wonder what's the location of `REAUIKit.h`. Obviously, the
file is located in
`react-native-reanimated/packages/react-native-reanimated/apple/reanimated/apple/REAUIKit.h`
(using symlinks as a Development Pod), but the path is not included in
header search paths. Hence, I decided to add
`react-native-reanimated/packages/react-native-reanimated/apple/` to
header search paths. However, this can't be done using absolute paths
because they are likely to be machine-specific (e.g. containing the home
directory name) which also affects checksum in Podfile.lock which is
inconvenient since some setups assume the checksum to be stable (unless
the version of the library is changed) due to security concerns.

A better idea would be to take inspiration from react-native itself.
I've noticed that `ReactCommon` has a similar feature – the headers are
in nested subdirectories (e.g. `react/renderer/core/ShadowNode.h`) and
the imports don't assume flat structure (e.g. it's `#import
<react/renderer/core/ShadowNode.h>` instead of `#import
<ReactCommon/ShadowNode.h>`).

I remembered that frameworks create `FrameworkName.framework`
directories. I finally found `RNReanimated.framework` in Xcode build
folder that you can open from menu bar:

<img width="312" alt="Screenshot 2024-10-18 at 18 04 45"
src="https://github.com/user-attachments/assets/1db95b44-d21c-4e9a-a1d5-19674093094b">

Taking a quick look inside and comparing `ReactCommon` and
`RNReanimated`, I've noticed that `RNReanimated.framework` doesn't
contain any header files (except for umbrella header) while
`ReactCommon` does:

<img width="1178" alt="Screenshot 2024-10-18 at 18 05 33"
src="https://github.com/user-attachments/assets/2633ab64-a85e-4a04-b2b3-97a11e576d6c">

When I commented out all 3 occurrences of `header_mappings_dir` in
RNReanimated.podspec and run the Xcode build (first build lasts until
the first error, if you hit the play button once again then, I assume it
runs the remaining tasks), the headers were finally there but the
directory structure was flattened:

```diff
-ss.header_mappings_dir = "Common/cpp/reanimated"
+#ss.header_mappings_dir = "Common/cpp/reanimated"
```

<img width="1178" alt="Screenshot 2024-10-18 at 18 14 52"
src="https://github.com/user-attachments/assets/c25c1dfe-ce45-45ff-856f-be005907ffe2">

Then I tried passing an absolute path to appropriate directories to see
if this would fix the structure:

```diff
-ss.header_mappings_dir = "Common/cpp/reanimated"
+ss.header_mappings_dir = "/Users/tomekzaw/RNOS/react-native-reanimated/packages/react-native-reanimated/Common/cpp"

-sss.header_mappings_dir = "apple/reanimated"
+sss.header_mappings_dir = "/Users/tomekzaw/RNOS/react-native-reanimated/packages/react-native-reanimated/

-ss.header_mappings_dir = "Common/cpp/worklets"
+ss.header_mappings_dir = "/Users/tomekzaw/RNOS/react-native-reanimated/packages/react-native-reanimated/Common/cpp"
```

Then I investigated `ReactCommon.podspec` inside react-native repository
and found several interesting lines of code:

```rb
s.header_dir = "ReactCommon" # Use global header_dir for all subspecs for use_frameworks! compatibility
```

It looks like `header_dir` must contain `header_mappings_dir` for the
latter to work properly when `use_frameworks!` is enabled.

```rb
if ENV['USE_FRAMEWORKS']
  s.header_mappings_dir     = './'
end
```
For some reason, `s.header_mappings_dir` is set to the current directory
only if `USE_FRAMEWORKS` is set.

...

```
HEADER_SEARCH_PATHS = (
	"$(inherited)",
	"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
	"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
	"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
	"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
	"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
	"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
	"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
	"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
);
```
@tomekzaw
Copy link
Member

@ethanneff Nope, 3.16.0 is fine except for just one configuration so we won't remove it. We'll publish 3.16.1 with the fix.

@efstathiosntonas I've just merged #6614, it will be included in 3.17.0-nightly, could you please give it a try once the nightly is out? Thanks in advance.

@efstathiosntonas
Copy link
Contributor Author

@tomekzaw sure thing, will report back tomorrow morning.

@efstathiosntonas
Copy link
Contributor Author

@tomekzaw tested 3.17.0-nightly-20241018-16297eb3c and life got back to normal.

@tomekzaw
Copy link
Member

@efstathiosntonas Thanks for checking! We'll publish 3.16.1 with the fix early next week.

@tomekzaw tomekzaw pinned this issue Oct 21, 2024
@tomekzaw tomekzaw unpinned this issue Oct 21, 2024
@tomekzaw tomekzaw pinned this issue Oct 21, 2024
tomekzaw added a commit that referenced this issue Oct 21, 2024
Fixes
#6607.

This is more of a workaround to fix issue with missing headers when
building Reanimated with static linkage for iOS. I spent several hours
on trying to make it right but it would work correctly only partially. I
will post my findings here or internally later on and I hope to find a
better solution sometime in the future.

This workaround adds paths to `Common/cpp` and `apple/` directories to
`HEADER_SEARCH_PATHS` – the preprocessor looks for headers in these
locations. I can't use an absolute path (calculated in Ruby) because it
would make the output setup-dependent and thus affect checksums in
`Podfile.lock` which is unwanted as some apps check against checksum
changes on CI.

Tested on fabric-example app with `USE_FRAMEWORKS=static` and without.

---

When installing pods in `fabric-example` with `cd ios && bundle install
&& bundle exec pod install`, the headers are visible in `ios/Pods`
directory:

```
$ find . -name "REAUIKit.h"
./Pods/Headers/Public/RNReanimated/reanimated/apple/REAUIKit.h
./Pods/Headers/Private/RNReanimated/reanimated/apple/REAUIKit.h
```

However, after running `USE_FRAMEWORKS=static bundle exec pod install`,
the headers are no longer present:

```
$ find . -name "REAUIKit.h"
<no output>
```

Because of this, `#import <reanimated/apple/REAUIKit.h>` doesn't work,
but when changed back to `#import <RNReanimated/REAUIKit.h>` it works
fine (jump to file also works in Xcode).

This made me wonder what's the location of `REAUIKit.h`. Obviously, the
file is located in
`react-native-reanimated/packages/react-native-reanimated/apple/reanimated/apple/REAUIKit.h`
(using symlinks as a Development Pod), but the path is not included in
header search paths. Hence, I decided to add
`react-native-reanimated/packages/react-native-reanimated/apple/` to
header search paths. However, this can't be done using absolute paths
because they are likely to be machine-specific (e.g. containing the home
directory name) which also affects checksum in Podfile.lock which is
inconvenient since some setups assume the checksum to be stable (unless
the version of the library is changed) due to security concerns.

A better idea would be to take inspiration from react-native itself.
I've noticed that `ReactCommon` has a similar feature – the headers are
in nested subdirectories (e.g. `react/renderer/core/ShadowNode.h`) and
the imports don't assume flat structure (e.g. it's `#import
<react/renderer/core/ShadowNode.h>` instead of `#import
<ReactCommon/ShadowNode.h>`).

I remembered that frameworks create `FrameworkName.framework`
directories. I finally found `RNReanimated.framework` in Xcode build
folder that you can open from menu bar:

<img width="312" alt="Screenshot 2024-10-18 at 18 04 45"
src="https://github.com/user-attachments/assets/1db95b44-d21c-4e9a-a1d5-19674093094b">

Taking a quick look inside and comparing `ReactCommon` and
`RNReanimated`, I've noticed that `RNReanimated.framework` doesn't
contain any header files (except for umbrella header) while
`ReactCommon` does:

<img width="1178" alt="Screenshot 2024-10-18 at 18 05 33"
src="https://github.com/user-attachments/assets/2633ab64-a85e-4a04-b2b3-97a11e576d6c">

When I commented out all 3 occurrences of `header_mappings_dir` in
RNReanimated.podspec and run the Xcode build (first build lasts until
the first error, if you hit the play button once again then, I assume it
runs the remaining tasks), the headers were finally there but the
directory structure was flattened:

```diff
-ss.header_mappings_dir = "Common/cpp/reanimated"
+#ss.header_mappings_dir = "Common/cpp/reanimated"
```

<img width="1178" alt="Screenshot 2024-10-18 at 18 14 52"
src="https://github.com/user-attachments/assets/c25c1dfe-ce45-45ff-856f-be005907ffe2">

Then I tried passing an absolute path to appropriate directories to see
if this would fix the structure:

```diff
-ss.header_mappings_dir = "Common/cpp/reanimated"
+ss.header_mappings_dir = "/Users/tomekzaw/RNOS/react-native-reanimated/packages/react-native-reanimated/Common/cpp"

-sss.header_mappings_dir = "apple/reanimated"
+sss.header_mappings_dir = "/Users/tomekzaw/RNOS/react-native-reanimated/packages/react-native-reanimated/

-ss.header_mappings_dir = "Common/cpp/worklets"
+ss.header_mappings_dir = "/Users/tomekzaw/RNOS/react-native-reanimated/packages/react-native-reanimated/Common/cpp"
```

Then I investigated `ReactCommon.podspec` inside react-native repository
and found several interesting lines of code:

```rb
s.header_dir = "ReactCommon" # Use global header_dir for all subspecs for use_frameworks! compatibility
```

It looks like `header_dir` must contain `header_mappings_dir` for the
latter to work properly when `use_frameworks!` is enabled.

```rb
if ENV['USE_FRAMEWORKS']
  s.header_mappings_dir     = './'
end
```
For some reason, `s.header_mappings_dir` is set to the current directory
only if `USE_FRAMEWORKS` is set.

...

```
HEADER_SEARCH_PATHS = (
	"$(inherited)",
	"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
	"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
	"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
	"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
	"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
	"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
	"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
	"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
);
```
@tomekzaw
Copy link
Member

Please upgrade to https://github.com/software-mansion/react-native-reanimated/releases/tag/3.16.1.

yarn add react-native-reanimated@^3.16.1

@Anaskhan143

This comment was marked as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing repro This issue need minimum repro scenario Platform: iOS This issue is specific to iOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants