Duplicate symbols due to git submodule + Swift package

I have an app that depends on UILibrary via git submodules. My app also needs to depend on FeaturePackage, which in turn depends on UILibrary via SPM.

When I tried adding FeaturePackage into my app, I started getting errors:

X duplicate symbols for architecture arm64

I'm guessing that's because adding FeaturePackage also added UILibrary, which was already present in my app via the git submodule.

How do I resolve this?

if i understand correctly, your using xcode?

if so, what i think you can do is weak link (change from "required" → "optional" in linked frameworks and libraries) for uilibrary that you depend on directly

if its an xcframework, make sure uilibrary is not copied (remove from frameworks copy phase) in the final build product (it should link with the one included indirectly via featurepackage dependency as long as its static lib iirc)

if its a pure spm project i'm not sure how to handle that tbh (i've never encountered that issue in spm-only projects)