software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.97k stars 1.3k forks source link

2.0.0 stable build error on iOS - `hidden_headers/Logger.h` not found #1805

Closed levibuzolic closed 3 years ago

levibuzolic commented 3 years ago

Description

Upgrading from 2.0.0-rc.3 to 2.0.0 produces an error when building for iOS, 2.0.0-rc.3 is working without issue.

[12:46:26]: ▸ Linking React
[12:46:26]: ▸ Compiling WorkletsCache.cpp
[12:46:26]: ▸ Compiling WorkletEventHandler.cpp
[12:46:26]: ▸ Compiling UIResponder+Reanimated.mm
[12:46:26]: ▸ Compiling ShareableValue.cpp
[12:46:26]: ▸ Compiling Scheduler.cpp
[12:46:26]: ▸ Compiling RuntimeDecorator.cpp
[12:46:26]: ▸ ❌  /Users/levi/src/project/native/node_modules/react-native-reanimated/Common/cpp/headers/Tools/ReanimatedHiddenHeaders.h:10:14: '../../hidden_headers/Logger.h' file not found
[12:46:26]: ▸     #include "../../hidden_headers/Logger.h"
[12:46:26]: ▸ ^

This appears to be related to #1775 however I haven't been able to find any reports of others facing the same issue and beleive that it's likely related to something specific in our brownfield app, but haven't been able to find a way to solve it in userland.

I'm not sure this is necessarily a bug, but any pointers on resolving it would be incredibly helpful.

Screenshots

image

Steps To Reproduce

I'm trying to put together a minimal reproduction, but our app is quite large closed source, so I haven't been able to extract a reproduction yet. At this stage I'm looking for tips/suggestions.

Expected behavior

App builds.

Actual behavior

App build fails. 😅

Snack or minimal code example

TBD

Package versions

github-actions[bot] commented 3 years ago

Issue validator

The issue is valid!

piaskowyk commented 3 years ago

Yes, we moved these header files to another location. Did you run pod install again after the update? Sorry if it is obviously for you. At first, You can try something like this:

//in project root directory
cd ./ios/Pods && rm -rf ./* && cd .. && pod deintegrate && pod install

If this doesn't help, I'll investigate this problem.

levibuzolic commented 3 years ago

Thanks for the fast reply and suggestion @piaskowyk -- hadn't tried pod deintegrate previously but looks like the result is the same. Have made sure to do a fresh install of all node_modules, pods and tried cleaning, but to no avail yet. We're getting the same result in our CI environment too.

I can see in the cpp directory that the hidden_header folder doesn't seem to be getting linked into the project the way I'd expect, they're present in the file system though. I'll try experimenting with the podspec tomorrow to see if I can work anything out.

Project

image

image

Filesystem

image

piaskowyk commented 3 years ago

It'll be really helpful for me if you can try to run this example app and let me know does it work for you.

levibuzolic commented 3 years ago

@piaskowyk yep, can run and build the playground without issue. I suspect this is related to something specific to our brownfields app. I'll keep digging to see if I can figure anything out.

image

karo-dc commented 3 years ago

Hi guys, @piaskowyk I have same issue. can not build.

Screen Shot 2021-03-08 at 3 05 37 PM Screen Shot 2021-03-08 at 3 04 42 PM
jakub-gonet commented 3 years ago

Some ideas to try: https://stackoverflow.com/questions/5198905/h-file-not-found https://stackoverflow.com/questions/33691707/xcode-cant-find-header-file

BTW, do you use Swift by any chance?

EDIT: since you use Swift I'll add one more link that maybe is relevant: https://developer.apple.com/forums/thread/69606?answerId=283546022#283546022

levibuzolic commented 3 years ago

Thanks @jakub-gonet , will give those suggestions a try in the morning.

Yes, our app uses a good amount of swift, we’re also using swift for AppDelegate instead of Objective-C.

karo-dc commented 3 years ago

@levibuzolic have you found any solution?

piaskowyk commented 3 years ago

@karo-dc I'm working on a solution now.

mrbrentkelly commented 3 years ago

I'm also hitting this. It appears the issue is related to using use_frameworks! in your Podfile:

Repro steps:

npx react-native init ReanimatedHeaderIssue --skip-install
cd ReanimatedHeaderIssue
yarn add react-native-reanimated@2.0.0
platform :ios, '10.0'

+use_frameworks!

target 'ReanimatedHeaderIssue' do
mrousavy commented 3 years ago

use_frameworks! causes a lot of issues with React Native, so let's stay away from that. This is related to how CocoaPods flattens out headers and preserves paths for hidden headers (hides them).

I'm not exactly sure what the problem on your end is, but I cannot reproduce it in my/our project 🤔

mrbrentkelly commented 3 years ago

use_frameworks! causes a lot of issues with React Native, so let's stay away from that

Unfortunately I'm working in a RN project that requires use_frameworks! 🙈 and Reanimated2 alpha releases have worked in this project the entire time.

So far that's the only difference I can find that my RN project has to a vanilla RN project, and adding use_frameworks! to a brand new project causes the same ../../hidden_headers/Logger.h' file not found issue. I created a simple project that repo's it https://github.com/mrbrentkelly/reanimated2-logger-not-found.

Are you saying that once this issue is fixed then the fact I'm using use_frameworks! should be ok?

karo-dc commented 3 years ago

I have found solution, you can add it like static library and it will work.

pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

installer.pod_targets.each do |pod| pod.name.eql?('RNReanimated') def pod.build_type; Pod::BuildType.static_library # >= 1.9 end end end end

mrbrentkelly commented 3 years ago

I have found solution, you can add it like static library and it will work.

pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

installer.pod_targets.each do |pod| pod.name.eql?('RNReanimated') def pod.build_type; Pod::BuildType.static_library # >= 1.9 end end end end

Nice @karo-dc 👍 I've been using something similar as a workaround as well. Feels like a workaround though rather than a true solution... I remember React Native going through something similar a while ago when use_frameworks was causing issues. I believe this is the PR that fixed that https://github.com/facebook/react-native/pull/12089

Perhaps reanimated could do something similar with header search paths in its podspec to work for projects that use the use_frameworks flag?

levibuzolic commented 3 years ago

We're using use_frameworks! too for Swift, so it very likely that this is the cause.

Can confirm that setting the pod to static works and our app can be built without issue.

pre_install do |installer|
  installer.pod_targets.each do |pod|
    if pod.name.eql?('RNReanimated')
      puts "Link #{pod.name} as static_library"
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end
mrbrentkelly commented 3 years ago

Dug into this a bit more this morning and changing the paths slightly in ReanimatedHiddenHeaders.h allows a project that uses use_frameworks! to compile.

#if defined(ONANDROID)
    #include "Logger.h"
    #include "LoggerInterface.h"
    #include "SpeedChecker.h"
#else
-    #include "../../Logger.h"
-    #include "../../LoggerInterface.h"
-    #include "../../SpeedChecker.h"
+    #include "Common/cpp/hidden_headers/Logger.h"
+    #include "Common/cpp/hidden_headers/LoggerInterface.h"
+    #include "Common/cpp/hidden_headers/SpeedChecker.h"
#endif

Raised a PR with this suggested change https://github.com/software-mansion/react-native-reanimated/pull/1810

piaskowyk commented 3 years ago

Awesome! 🎉 Thanks all for your commitment and help!