Xcode 11 - multiple targets with same SPM dependency

Hello,
I was not able to find anything here related to the issue I will try to describe here or in JIRA.

I am Xcode 11.2 project with one application target, 4 app extension and one dynamic Swift framework.
I am trying to use package dependency in Xcode 11 and link RxSwift to App and the framework. App has also dependency on the framework target. However when I run the app and get to the point where it is trying to use RxSwift, there are issues like this:

failed to demangle superclass of FlatMap from mangled name '7RxSwift8ProducerCy7ElementAA25ObservableConvertibleTypePQy_G'

If I have the dependency only in the framework, everything works fine and I can use the RxSwift even in the app code (thanks to transitive dependencies), but semantically this is not correct as I am actually hard dependent in the app code as well on RxSwift.

Is this know issue or expected behavior? Is there any place I can find more information?

If the package is statically linked into the framework, and also statically linked into the application, then when the application dynamically loads the framework, you would have duplicate symbols causing all sorts of havoc.

One solution would be to create a separate framework (which will be dynamically linked) and that simply @_exported imports the package. Then you can use that dynamic framework from any number of co‐existing targets and it will still only be loaded once.

Yeah I know, I am looking for information if this is correct behavior, something to be solved, known issue, up-to-the-user kinda thing or what is it.

I hoped that if I try to link the SPM dependency into multiple targets it will solve this issue automatically for me by building the deps as dynamic frameworks for example and linking them correctly to desired targets.

I believe that wrapping dependency into framework target is just workaround rather than solution. Same as being careful about linking dependency just once in the overall project.

I don’t work for Apple, so I don’t know know how they see it or what their plans are. But as a fellow outsider, I agree that it would be a useful thing for Xcode to do automatically. It’s not really a SwiftPM issue though, so the place to ask the Xcode team for such a features would be Apple’s Feedback Assistant.

Terms of Service

Privacy Policy

Cookie Policy