react-native: When upgrading to 0.64-rc3, error: Cycle in dependencies between targets 'FBReactNativeSpec'

Description

When upgrading to 0.64-rc3, I was stuck for many hours today on this compliation error:

Cycle in dependencies between targets 'BVLinearGradient' and 'FBReactNativeSpec'.

The initial target is irrelevant; if I removed BVLinearGradient it would still happen for many different native libraries and FBReactNativeSpec.

React Native version:

0.64-rc3 on iOS

Steps To Reproduce

Repro was consistent in my project. Maybe has something to do with the fact that I use use_frameworks!, and in the latest sample Podfile React Native does not include this directive.

Workaround

I was able to workaround this issue (and thus want to document it here for others who may get stuck) by:

Navigating to the FBReactNativeSpec target in the Pods project and deleting [CP-User] Generate Specs step.

I then navigated in the terminal to:

<project>/node_modules/react-native/scripts

And I manually ran from the terminal:

./generate-specs.sh

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 11
  • Comments: 25 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Here is a proposed solution from @gmapnl in the react-native-screens project:

https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933

post_install do |installer|
  react_native_post_install(installer)
  
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
    end
    
    if (target.name&.eql?('FBReactNativeSpec'))
      target.build_phases.each do |build_phase|
        if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
          target.build_phases.move(build_phase, 0)
        end
      end
    end
  end
end

This is not resolved. Still happens on 0.64.x

We should probably ask FB to re-open this issue, since it seems clear that it is affecting multiple people and is not resolved in the release version.

@PeteTheHeat @janicduplessis Would you be willing to re-open this issue since this appears to be affecting a number of folks? (apologies in advance if I have at-mentioned the wrong people – your names came up related to the FBReactNativeSpec podspec file, per this link.)

@JB-CHAUVIN

Click on the Pods project on the left sidebar Go under Build Phases Make sure [CP-User] Generate Specs is before Headers

If you have the issue with BVLinearGradient, this fix is in https://github.com/react-native-linear-gradient/react-native-linear-gradient/pull/500 but has not been released yet. You should specify react-native-linear-gradient version from git like this

package.json

  "react-native-linear-gradient": "https://github.com/react-native-linear-gradient/react-native-linear-gradient#0e3af58",

It’s not a react native issue per se.

If you have a cycle issue that is mentioning another lib, you should update the lib or open an issue for the lib (and/or patch the lib by replacing in dependency React to React-Core like in the PR above (use https://www.npmjs.com/package/patch-package if needed).

If you have the cycle issue without any explicit deps except FBReactNativeSpec, you might need to have a look to https://github.com/facebook/react-native/issues/31149 where you will find a workaround.

Great thanks for the replies,

I can confirm that @tushar-singhal @paulxuca solution is working.

And I can confirm that we need a permanent fix for this problem !

Screenshot 2021-03-25 at 16 23 40 @JB-CHAUVIN when you select pods on left sidebar, select `FBReactNativeSpec ` and then you will see this

@esilverberg recommended fix works perfectly well. No need to for any more manual steps.

But still the underlying issue must be fixed in RN!

Workaround works but doing it each time we use pod install wasn’t a solution. In our case only getting rid of use_frameworks! helped. Luckily, it turned out that we don’t need it anymore

Is there a permanent patch for this? Because the fix works the problem is that we have to re-do it every time we run pod install

We’ve fixed this by moving the build phase that react native adds before the headers phase (It is added after by default)

I am pretty confident this is not an upgrade issue. Every single time I run pod install, I see [CP-User] Generate Specs re-added to FBReactNativeSpec and I must delete it each time to ensure the build does not fail with this message.