DylanVann / react-native-fast-image

🚩 FastImage, performant React Native image component.
MIT License
8.15k stars 1.5k forks source link

Unable to compile: Duplicate interface definition for class 'FLAnimatedImageView' #46

Closed DerJacques closed 6 years ago

DerJacques commented 7 years ago

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!

fredzhang commented 7 years ago

same problem here. please help

mortezaalizadeh commented 7 years ago

Same problem here :)

denny64 commented 7 years ago

+1

jacksontbryan commented 7 years ago

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.

srameshr commented 7 years ago

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

MrLoh commented 6 years ago

I'm also encountering this issue. No idea how to fix it, or where it suddenly came form.

ruipaulo commented 6 years ago

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

i6mi6 commented 6 years ago

Cmd + Shift + K did it for me

jgbaEmento commented 6 years ago

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

kasran15 commented 6 years ago

Product -> Clean did the trick. Good suggestion!

pratt3351 commented 6 years ago

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

bonlemuel commented 6 years ago

@rouge3351 Thanks for your solution. Saved me lots of time figuring it out. :)

luco commented 6 years ago

None of proposed fixes works for me.

MrLoh commented 6 years ago

@luco did you really try all three things?

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.

luco commented 6 years ago

@MrLoh Apparently doing this steps the error went away. I'll be monitoring this. Thanks a lot!

hoscarcito commented 6 years ago

This is really annoying indeed. I'm subscribing for news!

broskoski commented 6 years ago

Same problem here. Running Project -> Clean and wiping the derived data folder did not work for me. If it helps at all, my project is set up with CocoaPods (though I manually linked the library in the build phases).

ruipaulo commented 6 years ago

@broskoski Did you do all the above suggested steps in @MrLoh 's last comment?

broskoski commented 6 years ago

@ruipaulo thanks, yes I did.

danmatthews commented 6 years ago

Also had this problem and couldn't solve it by performing all of the above steps.

I'm on a detached expo project, which means that i don't have an ios/build folder, so i couldn't do that one.

Had to uninstall as it was preventing me from building entirely.

DylanVann commented 6 years ago

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.

ruipaulo commented 6 years ago

@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.

foggy1 commented 6 years ago

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.

DannyAlb commented 6 years ago

I do not recommend doing this, but our extremely unacceptable and voodoo workaround was that after trying to build normally and getting above errors, to build the FastImage project separately, and add the library statically to the project (the libFastImage.a).

Unacceptable, voodoo, but the only way we got it to works :)

brenwell commented 6 years ago

I am wondering if the issue is caused because there is actually a duplicate?

Looks like its included twice.

I'm no xcode expert though

screen shot 2018-04-06 at 09 05 13
hoscarcito commented 6 years ago

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?

tomauty commented 6 years ago

@brenwell They are the same file. Not sure why it's included twice but if that could be resolved, all users here could finally check Parallelize Builds again...

oferRounds commented 6 years ago

+1

DylanVann commented 6 years ago

I'm looking into it a bit more. I have run into this.

I cannot replicate the issue on a new project though.

brenwell commented 6 years ago

The issue seems to come and go. Personally I find it easier to replicate via ‘react-native run-ios ‘ than via Xcode. Perhaps that helps

DylanVann commented 6 years ago

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

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

brenwell commented 6 years ago

Awesome. Will check thanks

VicFrolov commented 6 years ago

Getting same issue on version 4.0.4

Removed build folder, removed node modules, cleared watchman, installed node modules, npm reset cache, deleted all derived data. cleared xcode cache. Not sure what else to do :/

brenwell commented 6 years ago

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/
DylanVann commented 6 years ago

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

Ingibjorg commented 6 years ago

Thanks @DylanVann . This solved the issue for me 🙏

schlaegerz commented 6 years ago

I am on 4.0.8 and still getting this issue

DylanVann commented 6 years ago

You will probably still have this issue immediately after you upgrade to v4.0.8.

Do a clean build (xcode clean / rm -rf ios/build). I haven't seen this issue again since doing that.

luco commented 6 years ago

OK, I got this issue again and solved by doing a xcode clean and removing ios/build folder.

duro commented 5 years ago

@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.

dmkmedina commented 5 years ago

@duro Did you find a way to resolve this with the braze/appboy sdk? we're also having a similar issue

duro commented 5 years ago

@dmkmedina: Pinging @theonetheycallneo as he was the one on our team who got it sorted out. I'll be honest, it wasn't straightforward.

onurzorluer commented 5 years ago

Xcode 10 has a new build system. I had same problem in Xcode 10. I found that switching to the Legacy Build Systems solved the problem. To switch to the legacy build system do the following:

theonetheycallneo commented 5 years ago

@dmkmedina Our solution wasn't ideal, but we forked the react-native-fast-image and stripped out their SDWebImage.framework, then had their iOS project inherit from our parent umbrella iOS project: https://github.com/FreebirdRides/react-native-fast-image/commits/master

We then manually linked our parent iOS project to SDWebImage with Appboy's latest bundled release of SDWebImage.

Basically, we been manually linking frameworks on our umbrella, then we fork any conflicting libs and have them correctly inherit from the parent.

Hope that helps shed some light.

bnap00 commented 5 years ago

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)
atereshkov commented 5 years ago

Flutter: Just press Cmd + Shift + K in Xcode and then rebuild it.