[iOS][cocoapods] 'RCTAnimation/RCTValueAnimatedNode.h' file not found
skv-headless opened this issue · 69 comments
Description
'RCTAnimation/RCTValueAnimatedNode.h' file not found.
in current master https://github.com/facebook/react-native/tree/c233191485ef733aa7a8d4ea5c758b9e6a06964c
- related to 28 of march changes. @janicduplessis might help
- podspec test are passed. @alloy do you have ideas how tests could be improved?
Maybe we need to runxcbuild
to test?
Reproduction Steps and Sample Code
https://github.com/skv-headless/AwesomeProject - demo project based on this page https://facebook.github.io/react-native/docs/integration-with-existing-apps.html#cocoapods
Solution
It works if change #import <RCTAnimation/RCTValueAnimatedNode.h>
to #import "RCTValueAnimatedNode.h"
Additional Information
- Platform: [iOS]
- Development Operating System: [MacOS]
podspec test are passed. @alloy do you have ideas how tests could be improved?
Maybe we need to run xcbuild to test?
Nah, we should ideally build all the subspecs, I’ll take a look at how long those take.
@skv-headless Your example fails to build from a fresh clone with different issues than the one this ticket is about. Can you make sure it fails with the exact issue you mention from a fresh clone (so no pod install
, no npm install
) ?
While enabling full podspec testing I did encounter this failure, which is probably the one you’re referring to:
In file included from /Users/eloy/Code/React/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.m:10:
/Users/eloy/Code/React/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h:12:9: fatal error: 'RCTAnimation/RCTValueAnimatedNode.h' file not found
#import <RCTAnimation/RCTValueAnimatedNode.h>
Yep. This error. I've updated repo in case it still needed. Are you going to update test script?
Yeah I’ll do that, and then we’ll see how much time it takes to complete on CI.
I still get this error even in 0.44.0 where the code in RCTNativeAnimatedModule.h is updated from It works if change #import <RCTAnimation/RCTValueAnimatedNode.h> to #import "RCTValueAnimatedNode.h"
as mentioned by the original Bug logger. So the solution did not work for me.. Any other recommended solutions?
This is fixed as of 7b7d6bb @skv-headless
For those who still searching for a quick solution. I was able to launch iOS app with RCTAnimation subspec by including following string to my package.json:
"scripts": {
"postinstall": "sed -i '' 's\/#import <RCTAnimation\\/RCTValueAnimatedNode.h>\/#import \"RCTValueAnimatedNode.h\"\/' ./node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h",
...rest scripts
}
React: 16.0.0-alpha.12
ReactNative: 0.45.0-rc.0
Didn't work for me with above PR which already accepted in 0.45.0-rc.0
@egorkhmelev same for me. ss.header_dir
on Podspec didn't solve this issue.
this is a blocker for us too.. why is the issue closed? (13217)
Still get this error in RN 0.45.1
having this error too in v0.45.1
Getting the error in RN 0.45.1 as well
Please use this script in package.json
script
section.
"postinstall": "sed -i '' 's\/#import <RCTAnimation\\/RCTValueAnimatedNode.h>\/#import \"RCTValueAnimatedNode.h\"\/' ./node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h",
It will change #import <RCTAnimation/RCTValueAnimatedNode.h>
-> #import "RCTValueAnimatedNode.h
I use this script and it works but it's not a solution its a patch.. Also some of our teammates are working on Windows macines so this script will not work (I know there's an equivalent for Windows)
The point is that this should be solved the right way without using any hacking..
Right. Should be fixed
what command should I run after inserting the postinstall
script in the package.json?
I tried npm install
and pod install
but nothing changes
cd ios && pod install && cd ..
@littlehome-eugene you can try npm run postinstall
I got this issue upgrading to react native 0.47.1, any way to resolve it without hacks?
Does anyone tried to investigate real cause of this problem and find proper solution? All approaches mentioned here and in attached PRs do not look legit and almost certainly will not be merged.
isn't my solution that was posted here on July 3rd good enough? (the comment with the image attached)
@guysegal That file is not a part of React
module so it cannot be correct solution, right?
update:
I just upgraded to 0.50.3. Here's what I use in package.json
as a temporary solution. Thanks to @younatics .
It solves both RCTValueAnimatedNode.h
and fishhook.h
import errors. Hope it might save your time.
{
"scripts": {
"postinstall": "sed -i '' 's/#import <RCTAnimation\\/RCTValueAnimatedNode.h>/#import <React\\/RCTValueAnimatedNode.h>/' ./node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h; sed -i '' 's/#import <fishhook\\/fishhook.h>/#import <React\\/fishhook.h>/' ./node_modules/react-native/Libraries/WebSocket/RCTReconnectingWebSocket.m"
},
"dependencies": {
...
}
}
No luck after upgrading to 0.48.3. Have to use the postinstall script to solve it.
Did anyone try setting private_header_files
? We do use that in a few place in the pod config file. I'm pretty sure it's just a config issue, we should not have to change the import. Sorry about this taking so long to get resolved but we want to make sure we have the right fix.
@guysegal That file is not a part of React module so it cannot be correct solution, right?
@shergin, which file:
Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h or Libraries/NativeAnimation/Nodes/RCTValueAnimatedNode.h is not a part of React ?
@janicduplessis Documentation update needed for private_header_files
@shergin, Seems to be, You are right. Sorry.
Documentation is needed about adding native Libraries into project.
Still having this issue using 0.48.3
@iegik Did the private_header_files
thing I mentionned ended up working? It was just a wild guess haha
@janicduplessis This is not a joke - #15775
I've asked on the Cocoapods mailing list but I think it is correct to change the import to #import <React/RCTValueAnimatedNode.h>
.
I think this is because RCTAnimation
is only a subspec and will be built within the React.framework
when installed with Cocoapods. If RCTAnimation
would be a full-fledged pod then it would be possible to use #import <RCTAnimation/RCTValueAnimatedNode.h>
.
The header file RCTValueAnimatedNode.h
is a part of RCTAnimation
framework, so it should be
#import "RCTValueAnimatedNode.h"
inside RCTAnimation#import <RCTAnimation/RCTValueAnimatedNode.h>
outside RCTAnimation.
@yimingtang Are you sure about that? I think RCTAnimation isn't built as a full-fledged framework because it gets distributed as a subspec to React (which Cocoapods builds as the framework). So I think it should be:
#import "RCTValueAnimatedNode.h"
inside RCTAnimation#import <React/RCTValueAnimatedNode.h>
outside RCTAnimation becauseRCTValueAnimatedNode
is found withinReact.framework
.
There is a similar issue with fishhook
as well, see #16271 and #16039.
Hey guys, no idea what is the status of this with other people... but I am having the compilation error. Fixed it as per suggestion #import <React/RCTValueAnimatedNode.h>
Still get error with fishhook.h
and RCTValueAnimatedNode.h
, so I have to change it manually.
Have some errors after migration to RN 0.50.3
Same here, please fix this
In case you guys are not checking the other issue: guykogus provided a "fix" here #16039
Unfortunately, this has been on for sometime now and facebook is not paying attention to this :(
I think that we should push this up again.
Otherwise we will have always kind of hack
on our projects to make them work with Cocoapods
.
Thanks!
Not sure if this will help anyone, but I can avoid this issue if I remove use_frameworks!
from my Podfile
If you need to add use_frameworks!
, it seems like the postinstall script is the only way..
There is a common practice that I noticed in quite a few projects that deal with this issue. Here is how it would look like:
#if __has_include(<React/RCTValueAnimatedNode.h>)
#import <React/RCTValueAnimatedNode.h>
#else
#import "RCTValueAnimatedNode.h"
#endif
You can adjust this to your needs, e.g. if you want to cling to #import <RCTAnimation/RCTValueAnimatedNode.h>
for whatever reason, then just replace the first and second line appropriately.
This "trick" ensures best compatibility with use_frameworks!
and traditional methods.
Love your suggestion @p2k I think that should be the fix
Yep, the practice suggested by @p2k seems great.
This could be applied to: #17080 (and dupe) #16271
And also to:
#18050
Removing the need for this postinstall patch:
#17764 (comment)
Dependency hell / Conflicting dependencies
The roots of this issue goes from v0.40.0 update.
RN team decided to use React/*
prefix for importing dependencies. While other RN plugins still may use old importing pattern w/o prefixes. What will cause Duplicate declaration error.
- #15448 (comment)
- #11721 - maybe a solution
What build is the React Native team planning to put out a fix for this? Now that Swift has been around for a couple years and use_frameworks!
has become commonplace this seems like it really needs a fix. Maybe a trial branch so that folks can report errors and issues before release?
That is exactly my line. Doing an application completely in react native is practically unfeasible and most new software is been written in swift (and kotlin)
Duplicate declaration is inherently prevented by ObjC/clang's #import
instruction, except if the headers do exist twice, which is prevented with my proposed approach.
@younatics Your trick worked but i have to remove node_modules folder add the script in package.json and npm install . It worked in my case. Thank you for the trick .
Hi everyone, I've centralized a lot of the CocoaPods issues into a single project which will apply all of the post-install fixes for you, which should simplify integrating React Native with CocoaPods
its sad that even after an year, React-native iOS through Cocoapods is not seamless, you still have to patch around things
What version are you on @Abdul-Hannan?
The project I'm currently working on uses CocoaPods with React Native 0.55.3 without any issue.
Hello @jeanregisser , I am using 0.55.4
just added the pods as usual, but got this issue
Ok, and what version of CocoaPods?
I am using COCOAPODS: 1.5.0,
avoided issues by using @orta 's https://github.com/orta/cocoapods-fix-react-native
Please try again with 0.56.0-rc and let us know if that does not resolve the issue by leaving a comment here.
I can verify that RN 0.56.0-rc.2 does not resolve the issue.
Yup, it has not been fixed. This issue has been on for more than a year.
@jeanregisser This is still an issue with RN 0.56.0-rc.4
pod 'React', :path => REACT_NATIVE_PATH, :subspecs => [
'Core',
'CxxBridge', # Include this for RN >= 0.47
'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
'RCTAnimation',
'RCTActionSheet',
'RCTBlob',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket'
]
# Explicitly include Yoga if you are using RN >= 0.42.0
pod 'yoga', :path => "#{REACT_NATIVE_PATH}/ReactCommon/yoga"
# Third party deps podspec link
pod 'DoubleConversion', :podspec => "#{REACT_NATIVE_PATH}/third-party-podspecs/DoubleConversion.podspec"
pod 'glog', :podspec => "#{REACT_NATIVE_PATH}/third-party-podspecs/glog.podspec"
pod 'Folly', :podspec => "#{REACT_NATIVE_PATH}/third-party-podspecs/Folly.podspec"
try to add this to package.json and run it in your post-install:
"scripts": {
"fix:ios": "sed -i '' 's/#import <RCTAnimation\\/RCTValueAnimatedNode.h>/#import \"RCTValueAnimatedNode.h\"/' ./node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h"
}
Here is the project template which demonstrates this:
https://www.npmjs.com/package/react-native-vanilla
I upgraded my react-native to v0.56.0. once I run pod install
before building iOS. It works. My solution is
- Update react-native@0.56.0
- cd ios && pod install
- react-native run-ios
For those who are still experiencing the issue. Try the following:
rm -rf ~/Library/Developer/Xcode/DerivedData/
- Inside the
ios
folder, do
rm -rf "`pwd`/Pods/"
rm -rf "${HOME}/Library/Caches/CocoaPods"
- Run
pod install
- Open
xcworkspace
- Product > Clean
- Product > Clean Folder (Must hold the option key)
- Build
Good luck!
I am using COCOAPODS: 1.5.0,
avoided issues by using @orta 's https://github.com/orta/cocoapods-fix-react-native
This library only removes import strings. that were not automatically linked. It's not a solution to remove import code for fixing bugs because it may cause crash