Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cycle in dependencies between targets 'LottieLibraryIOS' and 'LottieReactNative' #385

Closed
p-grzelczak opened this issue Sep 24, 2018 · 45 comments

Comments

@p-grzelczak
Copy link

p-grzelczak commented Sep 24, 2018

Description

Getting this on react-native run-ios:

Build system information

error: Cycle in dependencies between targets 'LottieLibraryIOS' and 'LottieReactNative'; building could produce unreliable results.
Cycle path: LottieLibraryIOS → LottieReactNative → LottieLibraryIOS
Cycle details:
Target build order preserved because “Parallelize Build” is off

→ Target 'LottieLibraryIOS' has copy command from '/Users/username/Workspace/projectName/node_modules/lottie-ios/lottie-ios/Classes/PublicHeaders/Lottie.h' to '/Users/username/Workspace/projectName/ios/build/Build/Products/Debug-iphonesimulator/include/Lottie/Lottie.h'
○ Target 'LottieLibraryIOS' has target dependency on Target 'LottieReactNative' due to target order in a “Target Dependencies” build phase or the scheme
→ Target 'LottieReactNative' has compile command with input '/Users/username/Workspace/projectName/node_modules/lottie-react-native/src/ios/LottieReactNative/LRNContainerView.m'


** BUILD FAILED **

Interestingly - the app builds and runs fine, lottie animations work fine - but the build is failed and obviously I'd like to avoid it.

I've followed installation steps to the letter (both automatic and manual), tried unlinking, removing, adding everything back again. Cleaning build folder doesn't help. Only first application build succeeds, if I'd run react-native run-ios again - I get the BUILD FAILED. Need to remove and readd lottie back again. Passing --reset-cache flag doesn't change anything.

Versions

react-native: 0.57.0
lottie-react-native: 2.5.8
lottie-ios: 2.5.0
xcode: 10 (new build system)

screen shot 2018-09-24 at 17 59 14

@Darwin-Ming
Copy link

react-community_lottie-react-native__lottie_wrapper_for_react_native_

laiwan_react_native_xcodeproj

@nicksmetBagaar
Copy link

@p-grzelczak I'm having the same issue, did you manage to fix yours?

@nicksmetBagaar
Copy link

Weird thing is that is works perfectly in the simulator ...

@p-grzelczak
Copy link
Author

@Darwin-Ming I've said I followed installation instructions to the letter and you have pointed me to same installation instructions, what's the point?

@nicksmetBagaar This is being weird. Seems like it's connected with another issue ( facebook/react-native#20774 ) - doing a fix with a postinstall step seemed to help in my case, however my buddy working on same repository still has this issue : /

@Darwin-Ming
Copy link

sorry, I missed that step.

it works to me.

Xcode 10.
lottie-react-native 2.3.2.

@nickarora
Copy link

Just reporting that we are experiencing the same issue; using the linked post-install script (to install third party dependencies) does not fix it our case.

As others have reported, despite the BUILD FAILURE, the app launches correctly and the Lottie animations work as expected.

@emilioicai
Copy link
Member

this should be fixed on 2.5.9

@robwalkerco
Copy link

I'm trying to add react-native-lottie (version 2.5.9) and running into a very similar issue -

error: Cycle in dependencies between targets 'Lottie_iOS' and 'LottieReactNative'; building could produce unreliable results.

react-native version - 0.57.2
react-native-lottie version - 2.5.9

The build does seem to work ok, other than the error making noise in the console.

@ViktorKjerrman
Copy link

I can confirm @robwalkerco error after upgrading react-native-lottie to 2.5.9. Though my build failed, the app would not launch and give this error:

error: Cycle in dependencies between targets 'Lottie_iOS' and 'LottieReactNative'; building could produce unreliable results.

Running react-native: 0.55.3.

@robwalkerco
Copy link

The only way I've managed to work around this issue so far, is by using the XCode Legacy build preference.

@rodrigoelp
Copy link
Contributor

Hi guys, doing a bit of research, the fix for this one is a bit tricky because of the way the new build system works.

After you include lottie.framework as part of your embedded frameworks, you need to scroll a bit down into the linked frameworks and libraries. Lottie will be there twice, once added automatically when you linked the project and once when the embedded framework as added. The problem here is, one is faded out and the other one does not have any opacity, remove the one that is faded and rebuild, this should remove your building issues and the cycle dependency xcode 10 is warning.

@1pocketaces1
Copy link

Target 'RCTBlob' has target dependency on Target 'Lottie_iOS' due to target order in a “Target Dependencies” build phase or the scheme

That is the issue I am having, and none of the above mentioned solutions work. Like with the others, the build fails but the app still runs in the simulator.

@rodrigoelp
Copy link
Contributor

Hi @1pocketaces1,

Could you please share the steps you followed?

I've just created the steps mentioned above (and in the tutorial) and did not get any dependency added to RCTBlob.

The only place I've found where the dependency is specified in in the actual app, which it has to because you link the framework.

screen shot 2018-11-06 at 9 11 44 am

My steps to create the new project were:

react-native init lotest
cd lotest
yarn add lottie-react-native
react-native link lottie-ios
react-native link lottie-react-native
open ios/lotest.xcodeproj

And in XCode, tap on the project, general tab, add lottie as an embedded framework and go into the linked frameworks and remove the faded lottie.framework (as that one is a mistake, I think).

@1pocketaces1
Copy link

I tried switching around the target orders and putting Headers before Compile Sources as recommended by the debugger, and still had no success. I am getting the above error even though I don't see any target dependencies for RCTBlob or any of the libraries that are included in the dependency loop.

Temp fixed by using Legacy Build, but would love to see a fix for production. I will keep trying to find one when I have time

@1pocketaces1
Copy link

@rodrigoelp yes I removed the faded binary, and I do not have any dependencies listed for RCTBlob or any other RCT libs, which is why this error is so puzzling.

@1pocketaces1
Copy link

And I am using RN 0.56, lottie-ios 2.5.0 and lottie-RN 2.5.9

@rodrigoelp
Copy link
Contributor

@1pocketaces1 may I ask how did you setup the project? Are you using npm install lottie-react-native or are you including it via cocoapods?

There is a sample project I've created here. It is configured to compile ts into js... but you should be able to easily change the index.js to register your component solving the issue.

Another point you need to be aware is, there is a problem with react native and xcode 10, super annoying that will give you a compilation error while is building the obj library. Unfortunately, the only real workaround to this is to run react-native run-ios more than once so the compilation builds the library without issues. Compiling in release mode does not have this issue (extremely bizarre)

@1pocketaces1
Copy link

@rodrigoelp the last paragraph of your post is where my issue is, the issue with XCode 10 building the libraries. For some reason it runs into a dependency loop, and thinks all of the RCT libraries have dependencies even though there are none in the project. I have not yet tried in release mode.

As to your question, I have been developing this project for a few months, I started with RN 0.54 and I am using yarn for package management. As for linking the libraries I used react-native link ... and then double check them all manually to make sure they're correct.

@rodrigoelp
Copy link
Contributor

Hi @1pocketaces1, unfortunately this is an issue an open issue in react native. That race condition I mentioned before is affecting react native development and facebook has not paid attention to it yet as they haven't moved their tools to xcode 10. XCode is trying to build libraries in parallel, then it understands these libraries depend between each other and tries to build them (again) clashing with the previous version. If you move RN to frameworks you do not have this issue... but that isn't the way react native works :\

I know it is frustrating, some people has submitted pull requests to get this fix but it has not been merged yet.

I do suggest you to move to RN 0.57.4 as fb has introduce lots of breaking changes. Not a quick fix but it goes more in-line with the general direction the libraries are moving.

@1pocketaces1
Copy link

@rodrigoelp thanks for the info. I have kept use of a minimal amount of third party libraries so hopefully the change won't be too difficult aside from the react-native core changes, and will keep an eye on this issue

@cloudy-ninja
Copy link

same issue
React Native: 0.57.5
lottie-react-native: 2.5.11

Any solution yet?

@emilioicai
Copy link
Member

Ok, I'm reopening this as more people are being affected by this build issue.

@emilioicai emilioicai reopened this Feb 7, 2019
@rmilejcz
Copy link

rmilejcz commented Feb 7, 2019

I also catalogued this here: #440

For those affected by this, at least in my experience, cleaning your build cache (cmd + shift + option + k) effectively "resets" the issue. It's not a fix, but it will ensure that you can continue development.

@luisfuertes
Copy link

In mi case react-native link add pods to Podfile. After i have to run pod install and dont copy Lottie.framework to Embedded binaries (It doesnt appear)

"react-native": "0.58.4"
"lottie-react-native": "2.5.10"

@VincenzoCarlino
Copy link

I solved (without pod) by adding this:
screenshot 2019-03-07 12 41 37
And set this in package.json:
"react-native": "0.58.6"
"lottie-react-native": "2.5.10"

@jr-k
Copy link

jr-k commented Apr 10, 2019

What's going on ? This is very annoying, someone has a real fix out there ?

@hemedani
Copy link

hemedani commented Apr 15, 2019

I have the same issue and every time i want to run on simulator and remove the node_modules and install that again ....

rm -rf node_modules
yarn install

and after that react-native run-ios

it's takes at least 5 minutes to complete the steps everytime!!! very boring ....

@DillionApple
Copy link

@hemedani same here

@rajivshah3
Copy link

rajivshah3 commented Apr 20, 2019

@VincenzoCarlino 's suggestion fixed the issue for me

@cspicuzza
Copy link

This solution #385 (comment) doesn't seem apply to xcode 10.2.1. Maybe I'm missing something?

Embedded frameworks and libraries are separate in the Build Phases tab.

@cloverich
Copy link

@cspicuzza re #385 (comment) -- I just "fixed" this on my system by clearing the metro cache. I"m on macos.

# After some exploring, I found the metro cache directory with this command
ls $TMPDIR | grep metro
metro-cache

# removed it
rm -rf $TMPDIR/metro-cache

# this then worked
react-native run-ios

@GabrielScalici
Copy link

It's a Xcode problem.
There is a shortcut to fix this issue, working for me.
In the Xcode, press command + shift + K to clean.
And press play button again.

@leethree
Copy link

it's not a fix. it's a temporary workaround.

@syntheticencounters
Copy link

Enabling "Parallelize Build" in your scheme's build settings should help resolve the issue without having to clean the build folder each time

@cspicuzza
Copy link

@syntheticencounters I've tried that and was able to develop locally. In return it caused my TestFlight builds to crash.

cvarley100 pushed a commit to iotaledger/trinity-wallet that referenced this issue Aug 5, 2019
* Mobile: Remove RN 0.57.5 patch

* Mobile: Upgrade to RN 0.58.6 and React 16.6.3

* Mobile: Upgrade to RNN 2.13.0

* Mobile/iOS: Link JavaScriptCore and switch to new build system

* Bump realm to 2.26.1

* Mobile: Update RN patch

* Mobile/iOS: Fix Lottie build order

See lottie-react-native/lottie-react-native#385

* Revert "Bump realm to 2.26.1"

This reverts commit 16e69cd.

* Mobile: Update to 0.59.10

* Mobile: Remove patches that are no longer needed

* Mobile: Revert unrelated dependency updates

These dependencies can be upgraded in a separate PR

* Mobile/Android: Use Gradle 'bin' version instead of 'all'

'all' includes documentation and other things that will bloat the download size

* Mobile: Bump react-native-navigation

* Mobile/Android: Use intl version of new JSC

* Mobile/Android: Use RNN config for 0.57.5+

* Mobile: Fix failing tests

* Mobile: Ensure react-native-navigation does not use vulnerable lodash

* Mobile: Finish RN upgrade

* Mobile: Fix react-native-modal-translucent bug

See listenzz/react-native-modal-translucent#26

* Mobile: Update react-native-svg and victory-native

* Mobile: Fix bugs introduced in RN 0.59 upgrade (#2087)

* Mobile: Fix topbar padding

* Mobile: Fix statusbar style regression

* Mobile: Fix linting errors

* Mobile: Fix prop types

* Mobile: Fix page transition animation regression
@PierreCapo
Copy link
Contributor

PierreCapo commented Aug 13, 2019

You can use https://github.com/taboulot/rn-game-over for a relatively fast workaround (faster than removing node_modules).

$ yarn global add rn-game-over

And whenever you got the cycle dependencies issue with lottie, do:

$ rn-game-over -o && react-native run-ios

It will clean your XCode builds and be able to launch the app again.

@msqar
Copy link

msqar commented Aug 24, 2019

Hey guys, it's throwing me this on LottieiOS:

Using on React-Native 0.60.4.
I followed every step. I have Lottie.framework on Embedded Frameworks and not on Link Binary with Libraries section.

Showing Recent Messages

Build target LottieLibraryIOS of project Lottie with configuration Debug

<unknown>:0: error: filename "TextCompositionLayer.swift" used twice: '/Users/marian-mac/Documents/dev/MyApp/node_modules/lottie-ios/lottie-swift/src/Private/LayerContainers/CompLayers/TextCompositionLayer.swift' and '/Users/marian-mac/Documents/dev/MyApp/node_modules/lottie-ios/lottie-swift/src/Private/LayerContainers/CompLayers/TextCompositionLayer.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

What is wrong here?

@adteague
Copy link

adteague commented Aug 24, 2019

@msqar did you follow the install instruction for RN 0.60+? That doesn’t look right IIRC.

@msqar
Copy link

msqar commented Aug 24, 2019

@adteague yes, im not using cocoapods.
Steps i followed:

  1. Installed it by yarn add lottie-react-native and yarn add lottie-ios@3.0.3.
  2. Manually linked them, because for some reason my autolink isn't working (i think it's an issue because i migrated from 0.59 to 0.60.4).
  3. Added LottieReactNative.xcodeproj and Lottie.xcodeproj into /Libraries within my project.
  4. Added the libLottie.a and libLottieReactNative.a into Link Binary With Libraries.
  5. Added Lottie.framework into my target's Embed Frameworks.
  6. Don't know why there's a Lottie_iOS (Lottie) inside Target Dependencies, attempted removing it but it throws an error saying "Cannot find module Lottie" on some React Native Lottie files. So I added it back.
  7. Added the flag LD_VERIFY_BITCODE to "NO". Took from some stackoverflow.
  8. Also, went to XCode's Project Settings and changed the Build System to Legacy Build System.
    Nothing seemed to work so far.

Versions:

"react": "16.8.6",
"react-native": "^0.60.4",
"lottie-ios": "^3.0.3",
"lottie-react-native": "^3.1.0",

@msqar
Copy link

msqar commented Aug 24, 2019

@adteague There seems to be an issue on 3.0.3 that is going to be solved on 3.0.6 but hasn't been released yet. I'd like to know how to solve it for now, though. Any ideas?

@msqar
Copy link

msqar commented Aug 24, 2019

I was able to solve the error above by removing the extra reference within the Lottie.xcodeproj. But now, i get a different error: "No such module Lottie" on react-native-lottie files.

@nileshpandey3
Copy link

You can use https://github.com/taboulot/rn-game-over for a relatively fast workaround (faster than removing node_modules).

$ yarn global add rn-game-over

And whenever you got the cycle dependencies issue with lottie, do:

$ rn-game-over -o && react-native run-ios

It will clean your XCode builds and be able to launch the app again.

This solved my issue

@msqar
Copy link

msqar commented Sep 1, 2019

Yes, works awesome for me now :) thanks everybody.

@adimshev
Copy link

adimshev commented Nov 4, 2019

Clear xCode cache on each build solved this problem for me (command + shift + K)
macOS 10.15.1
Xcode: 11.2
react: 16.8.3
react-native: 0.59.10
lottie-ios: 2
lottie-react-native: 2.6.1

@xxidbr9
Copy link

xxidbr9 commented Aug 22, 2022

This always work, clear previous build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests