facebook/react-native

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

esilverberg opened this issue ยท 25 comments

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

Make sure to update all your dependencies that rely on React as a dependency in podspec to a version that relies on React-Core. (Just ran into this issue a few hours ago)

Do you need help upgrading to a newer React Native version? Visit the Upgrade Support repository or use the upgrade helper to see the changes that need to be made to upgrade your app.

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.

I seem to be running into the same issue.
The workaround by @esilverberg does work but needs to be done after every pod install.

Showing All Messages
Cycle inside FBReactNativeSpec; building could produce unreliable results. This usually can be resolved by moving the shell script phase '[CP-User] Generate Specs' so that it runs before the build phase that depends on its outputs.
Cycle details:
โ†’ Target 'FBReactNativeSpec' has link command with output '/Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Products/Debug-iphoneos/FBReactNativeSpec/FBReactNativeSpec.framework/FBReactNativeSpec'
โ—‹ Target 'FBReactNativeSpec' has compile command with input '/Users/schmidi/Projects/git/xx-12/code/ios/Pods/Target Support Files/FBReactNativeSpec/FBReactNativeSpec-dummy.m'
โ—‹ That command depends on command in Target 'FBReactNativeSpec': script phase โ€œ[CP-User] Generate Specsโ€
โ—‹ Target 'FBReactNativeSpec' has copy command from '/Users/schmidi/Projects/git/xx-12/code/node_modules/react-native/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h' to '/Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Products/Debug-iphoneos/FBReactNativeSpec/FBReactNativeSpec.framework/Headers/FBReactNativeSpec.h'
โ—‹ That command depends on command in Target 'FBReactNativeSpec': script phase โ€œ[CP-User] Generate Specsโ€


Raw dependency cycle trace:

target:  ->

node: <all> ->

command: <all> ->

node: /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Products/Debug-iphoneos/FBReactNativeSpec/FBReactNativeSpec.framework/FBReactNativeSpec ->

command: target-FBReactNativeSpec-596df37657fef3d87ef16631abbc611bd8e73feadee6a8e5c14524fc300acaed-:Debug:Ld /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Products/Debug-iphoneos/FBReactNativeSpec/FBReactNativeSpec.framework/FBReactNativeSpec normal ->

node: /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Objects-normal/arm64/FBReactNativeSpec-dummy.o ->

command: target-FBReactNativeSpec-596df37657fef3d87ef16631abbc611bd8e73feadee6a8e5c14524fc300acaed-:Debug:CompileC /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Objects-normal/arm64/FBReactNativeSpec-dummy.o /Users/schmidi/Projects/git/xx-12/code/ios/Pods/Target Support Files/FBReactNativeSpec/FBReactNativeSpec-dummy.m normal arm64 objective-c com.apple.compilers.llvm.clang.1_0.compiler ->

node: <target-FBReactNativeSpec-596df37657fef3d87ef16631abbc611bd8e73feadee6a8e5c14524fc300acaed--phase1--cp-user--generate-specs> ->

command: Gate target-FBReactNativeSpec-596df37657fef3d87ef16631abbc611bd8e73feadee6a8e5c14524fc300acaed--phase1--cp-user--generate-specs ->

node: /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/DerivedSources/codegen-FBReactNativeSpec.log ->

command: target-FBReactNativeSpec-596df37657fef3d87ef16631abbc611bd8e73feadee6a8e5c14524fc300acaed-:Debug:PhaseScriptExecution [CP-User] Generate Specs /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Script-1E8DC3BEC0135B5B2A4A2B289C3C530F.sh ->

node: /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Script-1E8DC3BEC0135B5B2A4A2B289C3C530F.sh ->

command: target-FBReactNativeSpec-596df37657fef3d87ef16631abbc611bd8e73feadee6a8e5c14524fc300acaed-:Debug:WriteAuxiliaryFile /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Script-1E8DC3BEC0135B5B2A4A2B289C3C530F.sh ->

node: <target-FBReactNativeSpec-596df37657fef3d87ef16631abbc611bd8e73feadee6a8e5c14524fc300acaed--phase0-copy-headers> ->

command: Gate target-FBReactNativeSpec-596df37657fef3d87ef16631abbc611bd8e73feadee6a8e5c14524fc300acaed--phase0-copy-headers ->

node: /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Products/Debug-iphoneos/FBReactNativeSpec/FBReactNativeSpec.framework/Headers/FBReactNativeSpec.h ->

command: target-FBReactNativeSpec-596df37657fef3d87ef16631abbc611bd8e73feadee6a8e5c14524fc300acaed-:Debug:CpHeader /Users/schmidi/Projects/git/xx-12/code/node_modules/react-native/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Products/Debug-iphoneos/FBReactNativeSpec/FBReactNativeSpec.framework/Headers/FBReactNativeSpec.h ->

node: /Users/schmidi/Projects/git/xx-12/code/node_modules/react-native/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h/ ->

directoryTreeSignature: ๏ฟฝ ->

directoryContents: /Users/schmidi/Projects/git/xx-12/code/node_modules/react-native/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h ->

node: /Users/schmidi/Projects/git/xx-12/code/node_modules/react-native/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h ->

command: target-FBReactNativeSpec-596df37657fef3d87ef16631abbc611bd8e73feadee6a8e5c14524fc300acaed-:Debug:PhaseScriptExecution [CP-User] Generate Specs /Users/schmidi/Library/Developer/Xcode/DerivedData/xx-gvguladiqholtqeybzaixjacqpek/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Script-1E8DC3BEC0135B5B2A4A2B289C3C530F.sh

[!] FBReactNativeSpec has added 1 script phase. Please inspect before executing a build. See https://guides.cocoapods.org/syntax/podspec.html#script_phases for more information.

don't know if related, but I had similar problems and workaround works. but my issue was related to thing that I started ios build with yarn. it's related somehow to the fact that this Generate Specs is npm script and won't execute correctly if you run with yarn. after I tried just npx react-native run-ios from manual -> build success.

This is not resolved. Still happens on 0.64.x

marf commented

Same problem here.

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

Is there a release ?

Same problem goes for me, what is the solution ?

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

How did you do that ?

@JB-CHAUVIN

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

marf commented

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

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

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 !

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

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

software-mansion/react-native-screens#842 (comment)

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

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

But still the underlying issue must be fixed in RN!

The fix is not working for us in github actions... Not sure why.

Does anyone know if that's already fixed in any of the nightly builds?

Any updates on this? Just ran into this issue on 0.64.2.

MoOx commented

If you have the issue with BVLinearGradient, this fix is in react-native-linear-gradient/react-native-linear-gradient#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 #31149 where you will find a workaround.

@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 anyone finds that this fix doesn't work, deleting the [CP-User] Generate spec completely worked for me. App complies/runs as expected.

@JB-CHAUVIN

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

Sorry sir but could you be more specific . I am new to IOS everything works fine on Android but when setup to IOS it is not working . I have the script phase error .

This helped me

sudo arch -x86_64 gem install ffi
arch -x86_64 pod install

What worked for me is selecting Dependency order instead of Manual Order

Screen Shot 2022-01-25 at 12 07 31 PM