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

Do not raise an exception on a Swift Package dependency #881

Merged
merged 2 commits into from
May 16, 2022

Conversation

vincentisambart
Copy link
Contributor

Closes #743

As described in #743, if a project has a target depending on a Swift Package product, calling Project#host_targets_for_embedded_target would raise a project inconsistency exception, even though the project had nothing wrong. That method is used by CocoaPods, so any project using explicit dependencies on Swift Package products would not be able to use CocoaPods.

The exception was raised by PBXTargetDependency#native_target_uuid. I modified that method to return nil if the dependency is a Swift Package project, as there is no native target to return. I also made sure PBXTargetDependency#display_name properly returns the product name.

#
attribute :product_ref, String
has_one :product_ref, XCSwiftPackageProductDependency
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to change attribute to has_one to easily get the product name in the display_name method.

CHANGELOG.md Outdated
@@ -32,6 +32,10 @@
[lemonspike](https://github.com/LemonSpike)
[#709](https://github.com/CocoaPods/Xcodeproj/issues/709)

* Do not raise an exception on a Swift Package dependency.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please add two empty spaces at the end of this line for markdown formattin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@dnkoutso dnkoutso merged commit 51fb78a into CocoaPods:master May 16, 2022
@vincentisambart vincentisambart deleted the swiftpm-dependencies branch May 16, 2022 01:06
@vincentisambart
Copy link
Contributor Author

Thanks for the quick review!
Any plans to release 1.22 in the near future? It seems master has quite a few changes piled up.

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

Successfully merging this pull request may close these issues.

Crash When Swift Package PBXTargetDependency has no target or targetProxy
2 participants