Closed nikita-leonov closed 2 years ago
The issue reported on Swift Forums too, but without much of activities so far — https://forums.swift.org/t/linking-multiple-dynamic-libraries-that-depend-on-the-same-target-fails-with-ld-failing-due-to-missing-files/57382/2
Thanks for reporting @nikita-leonov :) That's pretty frustrating, but I think it's an SPM linking issue. I'm not entirely sure what we can do in the project to resolve it, but if you have any thoughts I'm happy to further discuss.
@freak4pc indeed seems like an SPM issue. Although I think there is an opportunity to improve the current products layout that may indirectly fix the issue. It seems like all dynamic products within the package depend on the same RxSwift
target. This will likely end up in symbol duplication if you link multiple dynamic libraries such as RxCocoa-Dynamic
and RxRelay-Dynamic
into the single end product. To fix issues like this common dependency products should be not within the same package, but in separate packages. This means RxSwift
likely needs to be defined as a separate package and in this way, it can be reused as dynamic across multiple Dynamic
products within RxSwift
infrastructure itself. This is definitely a suboptimal way of doing things, but the current state of SPM is likely the only experiment to try that may unblock this issue.
This fix is simple to validate, but I do not want to invest in it much unless we both agree it worth trying and adopting in case if fixes the problem.
I validated the setup where there is a separate package RxSwift
with RxSwift-Dynamic
target and where the top layer package where RxCocoa
and others refer to the RxSwift
. It does solve the problem above, as well as a general issue with RxSwift
symbols linked into multiple dynamic libraries.
I validated the setup where there is a separate package
RxSwift
withRxSwift-Dynamic
target and where the top layer package whereRxCocoa
and others refer to theRxSwift
. It does solve the problem above, as well as a general issue withRxSwift
symbols linked into multiple dynamic libraries.
Thanks for looking into it. Can you share how that looks ?
@nikita-leonov ping
@freak4pc Hmm, so I have a mixed set of news. I did update the post here https://forums.swift.org/t/linking-multiple-dynamic-libraries-that-depend-on-the-same-target-fails-with-ld-failing-due-to-missing-files/57382/2 it seems the issue I experienced was not SPM specific, but probably some environment issue. After some change in the environment that I was unable to trace yet the issue is not reproducible anymore. I still believe that libs layout where multiple products could be static and dynamic, meanwhile all of them depend on RxSwift
static target underneath may end up in the symbols duplication, but it is probably a discussion for a separate ticket. RxSwift
is an important dependency in our product, and we are working through SPM migration now, so be sure if there anything poping up I will follow up here :) Although I do think we can close this particular ticket for now unless I will find what actually happened :O
Happy to circle back to this. We also recently migrated everything over to SPM & Tuist and experienced no issues as well, so we're happy to hear anything you pop into.
Closing this for the time being, but feel free to comment or open a new issue if you find anything. Thanks!
Short description of the issue: When the package depends on multiple dynamic targets from
RxSwift
package it fails to compile withld
error.Expected outcome: I would expect the package to compile.
What actually happens: Building of
swift-dynamic-test
provided in the example below will fail with Command Ld failed with a nonzero exit code, and the actual reason underneath will be thatld
uses a path/Build/Products/Debug-iphoneos/PackageFrameworks/RxSwift-Dynamic.framework/RxSwift-Dynamic
while there is noRxSwift-Dynamic
inRxSwift-Dynamic.framework
. Meanwhile, there isRxSwift
in the folderRxSwift.framework
folder next to it. Moreover manually moving and renaming the file to the place whereld
tries to find it results in a successful build. Note: There is no use ofRxSwift
product library in the package file and it is unclear how the wholeRxSwift.framework
is being built as well as whyRxSwift-Dynamic.framework
exists on a disk butRxSwift-Dynamic
is not there, while other things are.Errors details:
Self-contained code example that reproduces the issue:
A library within a package depends on RxSwift-Dynamic and RxCocoa-Dynamic which are defined as dynamic in the RxSwift package.
Platform/Environment
How easy is it to reproduce? (chances of successful reproduce after running the self-contained code)
Xcode version:
Installation method:
I have multiple versions of Xcode installed: (so we can know if this is a potential cause of your issue)
Level of RxSwift knowledge: (this is so we can understand your level of knowledge and formulate the response in an appropriate manner)