react-native-unimodules icon indicating copy to clipboard operation
react-native-unimodules copied to clipboard

'React/RCTImageLoader.h' file not found

Open kelokchan opened this issue 5 years ago • 14 comments
trafficstars

I am trying to install this library but got this error when building for iOS. I followed the instructions and modified my Podfile and AppDelegate.m AppDelegate.h accordingly but still couldn't get pass this error.

Versions used:

"react-native-unimodules": "0.7.0-rc.4",
"react-native": "0.60.5",

kelokchan avatar Dec 11 '19 13:12 kelokchan

Hey, sorry you're having trouble, could you please provide me with a screenshot of Xcode showing the error?

sjchmiela avatar Dec 11 '19 13:12 sjchmiela

image

Here ya go.

And my Podfile

platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'

target 'xxx' do
  # Pods for xxx
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'Firebase/Analytics'

  target 'xxx' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
  use_unimodules!
end

kelokchan avatar Dec 11 '19 13:12 kelokchan

I have the same error on my project: 'React/RCTImageLoader.h' file not found

soyhares avatar Dec 11 '19 17:12 soyhares

Hm… Could you please check whether there is a file under ios/Pods/Headers/Public/React-Core/React/RCTImageLoader.h? And if not… where in ios/Pods is it? 🤔

sjchmiela avatar Dec 11 '19 19:12 sjchmiela

I have the same error. I made the following changes in UMReactNativeAdapter.m:

//#import <React/RCTImageLoader.h>
#import <React-RCTImage/React/RCTImageLoader.h>

and file: RCTImageLoader.h

//#import <React/RCTResizeMode.h>
#import <React-RCTImage/React/RCTResizeMode.h>

my config:

"dependencies": {
    "expo-font": "^8.0.0",
    "expo-gl": "^8.0.0",
    "expo-gl-cpp": "^8.0.0",
    "expo-three": "^5.3.0",
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-unimodules": "^0.7.0",
    "three": "^0.111.0"
  },

started successfully

UPDATE: I understood why the error turned out. So that you don’t manually edit something: "react-native-unimodules": "^0.7.0" for RN 0.61

for RN 0.60 need use "react-native-unimodules": "^0.6.0"

my new success config:

"dependencies": {
    "expo-gl": "^7.0.0",
    "expo-gl-cpp": "^7.0.0",
    "gl-react": "^3.17.2",
    "gl-react-expo": "^3.17.2",
    "gl-react-native": "^3.17.2",
    "expo-three": "^5.3.0",
    "react": "16.8.6",
    "react-native": "0.60.5",
    "react-native-unimodules": "^0.6.0",
    "three": "^0.111.0"
  },

vitas61 avatar Dec 14 '19 10:12 vitas61

I solved this issue by replacing the following lines.

#import <React/RCTImageLoader.h> Replace with #import <React/RCTImageLoaderProtocol.h>

_reloadImageCancellationBlock = [[_bridge moduleForClass:[RCTImageLoader class]] Replace with _reloadImageCancellationBlock = [[_bridge moduleForName:@"ImageLoader"]

rafaysaleem89 avatar Feb 10 '20 10:02 rafaysaleem89

@vitas61 I'm tesing #import <React-RCTImage/React/RCTResizeMode.h> and getting file not found, with RCTImageLoader import works. What can be wrong?

Luckygirlllll avatar Mar 25 '20 16:03 Luckygirlllll

same issue in react-native 0.60.0 and unimodules 0.9.0

baotoan1905 avatar Apr 15 '20 04:04 baotoan1905

Hm, I'm seeing this too.

@sjchmiela said:

Hm… Could you please check whether there is a file under ios/Pods/Headers/Public/React-Core/React/RCTImageLoader.h? And if not… where in ios/Pods is it? 🤔

I found a file called RCTImageLoader.h at ios/Pods/Headers/Public/React-RCTImage/React/RCTImageLoader.h.

I'm at:

  • react-native at v0.60.6
  • react-native-unimodules at v0.9.1. Just tested on v0.7.0; same error, same location of RCTImageLoader.h.
  • @unimodules/core at v5.1.2

chrisbobbe avatar Jun 01 '20 21:06 chrisbobbe

OK, during experimentation at these versions:

  • react-native at v0.60.6
  • react-native-unimodules at v0.7.0.
  • @unimodules/core at v5.0.0

either of the following changes to node_modules/@unimodules/react-native-adapter/ios/UMReactNativeAdapter.podspec, by itself, was sufficient to fix the "'React/RCTImageLoader.h' file not found" error thrown from UMReactNativeAdapter.m, and I got no more errors:

Pod::Spec.new do |s|
  # [...]
- s.dependency 'React-Core'
+ s.dependency 'React'
  s.dependency 'UMCore'
  s.dependency 'UMFontInterface'
end

or

Pod::Spec.new do |s|
  # [...]
  s.dependency 'React-Core'
+ s.dependency 'React-RCTImage'
  s.dependency 'UMCore'
  s.dependency 'UMFontInterface'
end

It seems the "React-Core" pod does not provide RCTImageLoader.h. "React-RCTImage" does. It seems like "React" does too; I think that's because React.podspec has s.dependency "React-RCTImage" (link).

I'm currently looking for a way to accomplish this without modifying node_modules in-place; I bet there's something I can do in my own Podfile.

I think it's probable that this issue affects people with higher react-native or react-native-unimodules versions than me? I don't see this change having been made in @unimodules/react-native-adapter; see current master.

chrisbobbe avatar Jun 01 '20 23:06 chrisbobbe

With either one of those fixes in place, and during experimentation at the following versions:

  • react-native at v0.60.6
  • react-native-unimodules at v0.9.1
  • @unimodules/core at v5.1.2

I got the following build error, in Pods/Development Pods/EXImageLoader/EXImageLoader.m:

'React/RCTImageLoaderProtocol.h' file not found

image

It appears that the Libraries/Image/RCTImageLoaderProtocol.h file in the React Native repo didn't exist until facebook/react-native@bf78d79, which is tagged as released in RN v0.61.0.

It looks like expo-image-loader newly depends on RCTImageLoaderProtocol.h in https://github.com/expo/expo/commit/4559b35a9f3df9fcdc9bd8fa5bae4b99a6cd4bf9, which I believe was released to NPM at version 1.0.1 (releases don't seem to have Git tags, but the RCTImageLoaderProtocol.h import is absent at the v1.0.0 release commit and it's present at the v1.0.1 release commit). So, we should be good to go as long as we can use expo-image-loader prior to 1.0.1, e.g., at 1.0.0.

In https://github.com/unimodules/react-native-unimodules/commit/d9e08b4a61ead4d95d82b70b8c9693d26f21a6ba, released in 0.8.0 (see changelog), react-native-unimodules started depending on expo-image-loader at ~1.0.0.

But "expo-image-loader at ~1.0.0 " resolves to 1.0.2 at the time of writing, unless you specifically tell it to pin to 1.0.0. This is possible but awkward; one can add the following to their package.json:

+ "resolutions": {
+  "react-native-unimodules/expo-image-loader": "1.0.0"
+ }

With that, and with one of the changes from https://github.com/unimodules/react-native-unimodules/issues/97#issuecomment-637180616 also applied to node_modules/expo-image-loader/ios/EXImageLoader.podspec, I get no build failures.

chrisbobbe avatar Jun 02 '20 00:06 chrisbobbe

I said:

I think it's probable that this issue affects people with higher react-native or react-native-unimodules versions than me? I don't see this change having been made in @unimodules/react-native-adapter; see current master.

I said:

and with one of the changes from https://github.com/unimodules/react-native-unimodules/issues/97#issuecomment-637180616 also applied to node_modules/expo-image-loader/ios/EXImageLoader.podspec

I'm curious about how (or if!) things have been working at the latest react-native-unimodules, even on later React Native versions, when "React" or "React-RCTImage" isn't declared as a dependency in UMReactNativeAdapter.podspec and EXImageLoader.podspec.

I wonder if it could be the line https://github.com/facebook/react-native/pull/25619/commits/04e387e95127a8ea566d013bf904580e46bc403f#diff-de9a3682dffb0a4b65cac2d2f15f880fR31 in PR https://github.com/facebook/react-native/pull/25619, merged in https://github.com/facebook/react-native/commit/8131b7bb7b4794e0e7003a6e3d34e1ebe4b8b9bc#diff-de9a3682dffb0a4b65cac2d2f15f880fR31, which is tagged as released in RN v0.61.0? I'm not 100% sure what's going on there; I don't really know what to make of the associated issue (https://github.com/facebook/react-native/issues/25349) since I don't really know what use_frameworks! does.

I haven't seen any guidance for library maintainers from React Native about whether to always use s.dependency "React" or to cherry-pick the individual pods you need (like "React-Core" and "React-RCTImage"). Certainly using the catch-all "React" means you don't really have to think about accidentally leaving out a React Native dependency. It also has the benefit of RN v0.59 compatibility; in RN v0.59, before facebook/react-native@2321b3fd7 landed, "React-Core" and friends could only be spelled with the "subspec" syntax, as "React/Core", etc. But the catch-all "React" worked fine then, as it does now.

chrisbobbe avatar Jun 02 '20 18:06 chrisbobbe

I am facing the same issue. Has anyone found a fix to this?

himanshu0128 avatar Jul 14 '20 14:07 himanshu0128

OK, during experimentation at these versions:

  • react-native at v0.60.6
  • react-native-unimodules at v0.7.0.
  • @unimodules/core at v5.0.0

either of the following changes to node_modules/@unimodules/react-native-adapter/ios/UMReactNativeAdapter.podspec, by itself, was sufficient to fix the "'React/RCTImageLoader.h' file not found" error thrown from UMReactNativeAdapter.m, and I got no more errors:

Pod::Spec.new do |s|
  # [...]
- s.dependency 'React-Core'
+ s.dependency 'React'
  s.dependency 'UMCore'
  s.dependency 'UMFontInterface'
end

or

Pod::Spec.new do |s|
  # [...]
  s.dependency 'React-Core'
+ s.dependency 'React-RCTImage'
  s.dependency 'UMCore'
  s.dependency 'UMFontInterface'
end

It seems the "React-Core" pod does not provide RCTImageLoader.h. "React-RCTImage" does. It seems like "React" does too; I think that's because React.podspec has s.dependency "React-RCTImage" (link).

I'm currently looking for a way to accomplish this without modifying node_modules in-place; I bet there's something I can do in my own Podfile.

I think it's probable that this issue affects people with higher react-native or react-native-unimodules versions than me? I don't see this change having been made in @unimodules/react-native-adapter; see current master.

Excellent, I did not try to solve it like that because I'm new in RN but what worked for me was to copy from "os/Pods/Headers/Public/React-RCTImage/React/~" all the files that Xcode could not find (In my case were 3 files) to "os/Pods/Headers/Public/React-Core/React/“

iruvingu avatar Jan 15 '21 17:01 iruvingu