trinhngocthuyen / cocoapods-spm

A CocoaPods plugin to add SPM dependencies to CocoaPods-based projects
MIT License
53 stars 10 forks source link

FEAT: Allow excluding dependency from top level (aggregate) target. #117

Closed Stannieman closed 1 month ago

Stannieman commented 1 month ago

Let's say you have a target A that depends on pod B. In B you want to use somePackage from SPM. To do this you add the spm_pkg => 'somePackage' and so on to the target in the Podfile. an then spm_dependency 'somePackage' to B's podspec. If pods are built as frameworks, this means that somePackage will be linked into pod B's framework and also to target A, even if target A does not need it. This needlessly increases A's binary size.

I added an option to not link somePackage to A.

It works, but it is of course possible I added this at the wrong level in code cause I don't fully know what I'm doing.

trinhngocthuyen commented 1 month ago

Hey, there. Thank for the contribution!

Actually, one of the design principle of this plugin is to align with how CocoaPods is handling dependencies. And with CocoaPods, a pod, regardless of whether it's being explicitly declared in Podfile, or being included as a dependency of another, is still being linked to the main target. Therefore, the current behavior for SPM packages is still consistent with how pods are treated.

Yet, I do agree with you that we should be given the option to opt out for the linking to the main target (as we should have been, in case of pods). So, yes, I'm good with the idea in this PR.

trinhngocthuyen commented 1 month ago

The change LGTM. Could you help fix the lint errors https://github.com/trinhngocthuyen/cocoapods-spm/actions/runs/11349092343/job/31564389693?pr=117?

You can run make format to format the code (or make the suggested changes as in the GH action runs)

Screenshot 2024-10-16 at 10 00 49 PM