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

Crash When Swift Package PBXTargetDependency has no target or targetProxy #743

Closed
jsorge opened this issue Mar 19, 2020 · 10 comments · Fixed by #881
Closed

Crash When Swift Package PBXTargetDependency has no target or targetProxy #743

jsorge opened this issue Mar 19, 2020 · 10 comments · Fixed by #881

Comments

@jsorge
Copy link
Contributor

jsorge commented Mar 19, 2020

When I have an Xcode project that has a SwiftPM package on it, and a target which depends on that project, I'm getting a crash in CocoaPods because the Xcodeproj gem is expecting a target or targetDependency value and SwiftPM target dependencies seem to use neither.

Stack trace:

RuntimeError - Expected target or target_proxy, from which to fetch a uuid for target ''.Find and clear the PBXTargetDependency entry with uuid 'D0380B7818F272B9D5595B72' in your .xcodeproj.
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/xcodeproj-1.15.0/lib/xcodeproj/project/object/target_dependency.rb:62:in `native_target_uuid'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/xcodeproj-1.15.0/lib/xcodeproj/project.rb:609:in `map'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/xcodeproj-1.15.0/lib/xcodeproj/project.rb:609:in `block in host_targets_for_embedded_target'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/xcodeproj-1.15.0/lib/xcodeproj/project.rb:607:in `select'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/xcodeproj-1.15.0/lib/xcodeproj/project.rb:607:in `host_targets_for_embedded_target'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:355:in `block (2 levels) in analyze_host_targets_in_podfile'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:354:in `each'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:354:in `flat_map'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:354:in `block in analyze_host_targets_in_podfile'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:353:in `each'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:353:in `analyze_host_targets_in_podfile'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:457:in `generate_targets'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:127:in `analyze'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:410:in `analyze'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:234:in `block in resolve_dependencies'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/user_interface.rb:64:in `section'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:233:in `resolve_dependencies'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:156:in `install!'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/command/install.rb:52:in `run'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/lib/cocoapods/command.rb:52:in `run'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/gems/cocoapods-1.8.4/bin/pod:55:in `<top (required)>'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/bin/pod:23:in `load'
/Users/jsorge/Develop/marco/vendor/bundle/ruby/2.6.0/bin/pod:23:in `<top (required)>'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:74:in `load'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:28:in `run'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:465:in `exec'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:27:in `dispatch'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/cli.rb:18:in `start'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/exe/bundle:30:in `block in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.0.2/exe/bundle:22:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'

Here's what that UUID looks like in my project file:

D0380B7818F272B9D5595B72 /* PBXTargetDependency */ = {
	isa = PBXTargetDependency;
	productRef = 84C7AC2A79AFD93970D5BC0C /* Time */;
};

This doesn't seem like a CocoaPods bug to me. Please correct me if I'm wrong. Thanks!

@jsorge jsorge changed the title Crash When Swift Package PBXTargetDependency has to target or targetProxy Crash When Swift Package PBXTargetDependency has no target or targetProxy Mar 19, 2020
@soffes
Copy link

soffes commented Jun 5, 2020

I'm also seeing this. Would love a solution.

@mycroftcanner
Copy link

same here

@jtyrie
Copy link

jtyrie commented Sep 11, 2020

Any update on this? I'm seeing the same issue

@jtyrie
Copy link

jtyrie commented Nov 27, 2020

I don't know if this information is useful but I'm seeing the following

Occurs given the following

  • One workspace with multiple projects.
  • Projects have SPM dependencies.

The odd bit is this:

  • Only occurs when there is the main projects and two or more other projects using pods.
  • If I comment out either of the additional two projects from the podfile the error does not occur.

@segiddins is there any idea whether this is likely to be looked at in the near future? Cheers

@mrackwitz
Copy link
Member

My naive conclusion would be that we'd need to weaken the internal consistency check in TargetDependency#native_target_uuid:

raise "Expected target or target_proxy, from which to fetch a uuid for target '#{display_name}'." \
"Find and clear the PBXTargetDependency entry with uuid '#{@uuid}' in your .xcodeproj."

Which is tested by:

it "raises if target and target_proxy aren't set" do
@target_dependency.name = 'TargetName'
@target_dependency.target.nil?.should == true
@target_dependency.target_proxy.nil?.should == true
should.raise do
@target_dependency.native_target_uuid
end.message.should.include "Expected target or target_proxy, from which to fetch a uuid for target 'TargetName'." \
"Find and clear the PBXTargetDependency entry with uuid '#{@target_dependency.uuid}' in your .xcodeproj."
end

As by the reference provided by @jsorge, there doesn't seem to be any other indication that this particular reference is populated by SPM, we might just need to take these two lines out and return nil here - if someone wants to tackle this. A minimal sample workspace reproducing this issue could be a helpful test fixture.

@jtyrie
Copy link

jtyrie commented Nov 30, 2020

Thanks @mrackwitz.

I've created a sample project here with some further notes.
https://github.com/jtyrie/CocoaPodsSPMCrashSample

@mthole
Copy link

mthole commented Feb 6, 2021

Bump here. Ran into this today.

@dalemyers
Copy link

Also seeing this.

1 similar comment
@JimRoepcke
Copy link

Also seeing this.

@TiagoAndreAlmeida
Copy link

I getting this erro too afte update my React Native project

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

Successfully merging a pull request may close this issue.

10 participants