React-native-fast-image: 'React/RCTResizeMode.h' file not found

Created on 29 Jun 2018  路  5Comments  路  Source: DylanVann/react-native-fast-image

I installed the plugin using this command yarn add DylanVann/react-native-fast-image.git because I need the feature from master branch.

However, I received the above error when building the iOS app. Does anyone know how to solve it?

Most helpful comment

I had the same problem. The link doesn't really work so you need to do the manual install. I did the cocoa pod instructions:

platform :ios, '9.0'

target 'ReactNativeFastImageCocoaPodsExample' do
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',
    'RCTImage',
  ]
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

+  pod 'react-native-fast-image', :path => '../node_modules/react-native-fast-image'
end

Make sure to include 'RCTImage',

You'll see here that RCTResizeMode is in React Image: https://github.com/facebook/react-native/blob/master/Libraries/Image/RCTResizeMode.m

The documentation should probably be updated to point this out.

All 5 comments

I had the same problem. The link doesn't really work so you need to do the manual install. I did the cocoa pod instructions:

platform :ios, '9.0'

target 'ReactNativeFastImageCocoaPodsExample' do
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTNetwork',
    'RCTWebSocket',
    'RCTImage',
  ]
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

+  pod 'react-native-fast-image', :path => '../node_modules/react-native-fast-image'
end

Make sure to include 'RCTImage',

You'll see here that RCTResizeMode is in React Image: https://github.com/facebook/react-native/blob/master/Libraries/Image/RCTResizeMode.m

The documentation should probably be updated to point this out.

@jedashford You're right, I didn't include RCTImage in my pod. Thanks, it works now!

After upgrade to "react-native-fast-image": "^6.0.0", I was getting the follow error:

SDWebImage/SDWebImageDownloader.h:92:48: Reference to 'SDWebImageOperation' is ambiguous

Using RCTImage at Podfile as @jedashford said, did work.

Updating to #import <React-RCTImage/React/RCTResizeMode.h> works well for me. I did it through Xcode, but I think it's also can be done through other editors, path: ios/pods/Headers/Private/RNFastImage/FFFastImageView.h & ios/pods/Headers/Public/RNFastImage/FFFastImageView.h

image

@jeafgilbert's solution worked for me. If manually editing the source files isn't a sustainable solution for you (due to CI, etc.), stick the following script at the end of your Podfile to automatically patch the offending files post pod install:

# Custom post install script to fix an compilation issue with React-Native-Fast-Image.
# See https://github.com/DylanVann/react-native-fast-image/issues/236#issuecomment-720935916 for more info.
# TODO Most likely this won't be needed anymore once you update React-Native to a later version.
post_install do |installer|
  bad_import = "<React/RCTResizeMode.h>"
  good_import = "<React-RCTImage/React/RCTResizeMode.h>"

  file_name = "pods/Headers/Private/RNFastImage/FFFastImageView.h"
  file = File.open(file_name)
  file_data = file.read
  file_data.sub! bad_import, good_import
  File.write(file_name, file_data)

  file_name = "pods/Headers/Public/RNFastImage/FFFastImageView.h"
  file = File.open(file_name)
  file_data = file.read
  file_data.sub! bad_import, good_import
  File.write(file_name, file_data)
end
Was this page helpful?
0 / 5 - 0 ratings