react-native-fast-image: Unable to compile: Duplicate interface definition for class 'FLAnimatedImageView'

Hi there!

I’m having problems compiling my app after adding react-native-fast-image.

After running react-native link react-native-fast-image, I receive a bunch of duplicate interface definition for class 'FLAnimatedImageView' and property has a previous declaration errors.

Here’s a subset of the errors I receive:

In file included from /Users/manuelthomsen/Coding/experiments/expo/woodn/node_modules/react-native-fast-image/ios/Vendor/SDWebImage/SDWebImage/FLAnimatedImage/FLAnimatedImageView+WebCache.m:16:
In file included from /Users/manuelthomsen/Coding/experiments/expo/woodn/node_modules/react-native-fast-image/ios/Vendor/SDWebImage/Vendors/FLAnimatedImage/FLAnimatedImage/FLAnimatedImage.h:13:
/Users/manuelthomsen/Coding/experiments/expo/woodn/node_modules/react-native-fast-image/ios/Vendor/SDWebImage/Vendors/FLAnimatedImage/FLAnimatedImage/FLAnimatedImageView.h:22:1: error: duplicate interface definition for class 'FLAnimatedImageView'
@interface FLAnimatedImageView : UIImageView
^
In module 'FLAnimatedImage' imported from /Users/manuelthomsen/Coding/experiments/expo/test/node_modules/react-native-fast-image/ios/Vendor/SDWebImage/SDWebImage/FLAnimatedImage/FLAnimatedImageView+WebCache.h:14:
/Users/manuelthomsen/Library/Developer/Xcode/DerivedData/test-ftzdxdyafvkexabeahltbammdnfq/Build/Products/Debug-iphonesimulator/FLAnimatedImage.framework/Headers/FLAnimatedImageView.h:22:12: note: previous definition is here
@interface FLAnimatedImageView : UIImageView
           ^
In file included from /Users/manuelthomsen/Coding/experiments/expo/test/node_modules/react-native-fast-image/ios/Vendor/SDWebImage/SDWebImage/FLAnimatedImage/FLAnimatedImageView+WebCache.m:16:
In file included from /Users/manuelthomsen/Coding/experiments/expo/test/node_modules/react-native-fast-image/ios/Vendor/SDWebImage/Vendors/FLAnimatedImage/FLAnimatedImage/FLAnimatedImage.h:13:
/Users/manuelthomsen/Coding/experiments/expo/test/node_modules/react-native-fast-image/ios/Vendor/SDWebImage/Vendors/FLAnimatedImage/FLAnimatedImage/FLAnimatedImageView.h:26:48: error: property has a previous declaration
@property (nonatomic, strong) FLAnimatedImage *animatedImage;

Any ideas on how to solve this? This is a basic expo app that has just been detached.

Tested on RN v. 46 and 47.

Thank you!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 26
  • Comments: 46 (5 by maintainers)

Most upvoted comments

Product-> Clean and then rm -rf ~/Library/Developer/Xcode/DerivedData/* did the trick for me.

@luco did you really try all three things?

  • rm -rf ~/Library/Developer/Xcode/DerivedData/*
  • rm -rf ios/build
  • in xcode <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>K</kbd>

Did you try building from xcode and command line

@DylanVann is there any chance you could look into fixing this in the code. This is sucha a terrible annoyance for everyone using this library and it happens regularly. I have no idea what has to be setup in xcode to make this disappear, but there must be something, as I haven’t gotten these errors from any other library.

Blowing away the contents of my ios/build folder cleared this for me. The error only happened from react-native run-ios and wasn’t reproducible from xcode directly.

@DylanVann I know, that it is probably super hard to find the bug that is causing this. On the other hand, it is happening consistently once or twice per week in our project. This is only and always caused by fast-image (we have also many other native libraries in the project). I know that there is probably no easy fix for this, but I think this issue should remain open as long as it is not fixed. Maybe at some point somebody might come up with a solution. This is a relevant bug, it is costing us at least an hour dev time per week and many users coming new to your library might spent hours trying to fix find a solution. This shouldn’t be perceived as nagging, we love your library, but this is a relevant bug.

I’ve just delete project/ios/build folder and command react-native run-ios and it works fine!

I haven’t seen the issue since I upgraded to 4.0.4 that doesn’t mean it won’t appear though

For anyone interested here is my clean all the things script

# react-native
    watchman watch-del-all
    rm -rf node_modules && npm install
    rm -rf $TMPDIR/haste-map-react-native-packager-*
    rm -rf $TMPDIR/react-native-packager-cache-*
    rm -rf $TMPDIR/metro-bundler-cache-*

# xcode
    xcodebuild -project ios/vs2.xcodeproj -configuration Release clean
    xcodebuild -project ios/vs2.xcodeproj -configuration Debug clean
    rm -rf ~/Library/Developer/Xcode/DerivedData
    rm -f /ios/build

 # cocoapods
    pod deintegrate --project-directory=./ios/
    rm -rf ./ios/Pods
    pod install --project-directory=./ios/
  • node_modules (rm -rf node_modules then yarn)
  • watchman cache (watchman watch-del-all)
  • react-native packager cache (react-native start --reset-cache)
  • react native build (rm -rf ios/build)
  • xcode clean
  • xcode derived data

There are a lot of places things can get cached and mess things up when using React Native. Try clearing all those and I’m certain you won’t have any more issues.

There’s not really anything I could do to this library that would prevent these issues. I have dealt with these issues using many other libraries.

IMO React Native should have a clean command that handles all of these cases.

I made some changes to the FastImage project that might fix this.

  • Set deprecated ALWAYS_SEARCH_USER_PATHS to NO. (e7ba4a7f789d883f4dbbe526612e70a2501d7be5)
  • Fix FLAnimatedImage header search path. (883dc0664dfd6ca26a1b8bece161abd3b9184cf1)
  • Remove FLAnimatedImage from FastImage project since it’s already included in SDWebImage. Installation remains the same as before when using CocoaPods. (a2d9fe2c71693721fec56e9cfe258a373a651b71)

The changes are published as v4.0.4. Please let me know wether or not you’re still experiencing this issue after upgrading.

same problem here … cleaning and deleting derived data does not work here

Cmd + Shift + K did it for me

As @foggy1 mention, this happens on fresh build environments, making it useless with CI tools. @brenwell I saw the same but I don’t understand how it works iOS nor why it works after cleaning the project. Any light over here?

@jacksontbryan Did that. It did not solve the problem for me. It occurs when building for iPhone 5s and iOS version 9.0

Currently, I am on

"react-native-firebase": "^5.1.0",

and I am facing

/node_modules/react-native-fast-image/ios/FastImage/FFFastImageView.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

@DylanVann we are seeing this on latest version of react-native-fast-image with React 0.57. Not sure if 0.57 has anything to do with it. The biggest problem is that we use CI to build our releases, which always start from a clean state. We are consistently getting the issue with every build.

One thing we have noticed is that another one of our dependencies, the Braze/Appboy SDK, also depends on SDWebImage.

Has any further light been shed on this issue? We are going crazy trying to make any progress on resolving this.

I am on 4.0.8 and still getting this issue

Thanks @DylanVann . This solved the issue for me 🙏

There were some issues with v4.0.4, they should be resolved in the latest version (v4.0.6). See: https://github.com/DylanVann/react-native-fast-image/issues/189

This happens in completely fresh build environments, e.g. when using continuous integration tools. It actually makes CI completely untenable with respect to iOS builds.

Product -> Clean did the trick. Good suggestion!