trinhngocthuyen / cocoapods-spm

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

[Bug] exclude_from_targets not always working #119

Closed Stannieman closed 3 weeks ago

Stannieman commented 4 weeks ago

What happened?

Hi!

Creating this issue mainly to ask a question.

Recently I did this PR, and at the time the part in target_dep_resolver.rb worked fine because there was at least 1 ds at that piont that had a pkg set. However, after some changes in my project (getting rid of all subspecs) the pkgs at that point are all nil, meaning it does not work anymore.

I tried moving this filtering to def spm_pkg(name, options) in podfile.rb, but even though at that point the filtering works, the library is still linked to these targets.

Could you point me to the correct place where filtering of dependencies based on exclude_from_targets should be done? Or is there no single place and I should implement it separately in all post_integrate steps?

CocoaPods environment

No response

Anything else?

No response

Stannieman commented 3 weeks ago

Another option would be to keep the check at the place where it is but check on dependency instead of the pkg inside it. But the dependency there has a nil options. If there is a way to get options set by that point it would also solve the problem.

trinhngocthuyen commented 3 weeks ago

So you mean a package is still linked to the aggregate targets (ex. Pods-Foo) despite being declared in the exclude_from_targets options?

If so, may be you wanna try adding the filter in spm_dependencies_for/spm_targets_for https://github.com/trinhngocthuyen/cocoapods-spm/blob/9e6ad0daba2a3c08c57149870c38756a845ce1b9/lib/cocoapods-spm/resolver/result.rb#L33-L44

This is the place we get spm dependencies/targets and make up the linker flags and other related build settings

Stannieman commented 3 weeks ago

Thanks! That works indeed. https://github.com/trinhngocthuyen/cocoapods-spm/pull/120