Closed sejr closed 2 years ago
Unfortunately this isn't going to be a straightforward fix, since it's a limitation of multiple frameworks that depend on the same framework in different ways.
If you're not using FirebaseMLModelDownloader, a quick workaround would be to create an alternative branch or fork, where SwiftProtobuf and FirebaseMLModelDownloader are removed from the Package.swift
.
If you are using it, then it's a bit more complicated. The collision error could be fixed by renaming the target, e.g. _SwiftProtobuf
, but then SwiftProtobuf.o
will be linked twice, which will result in "duplicate symbols for architecture..." errors.
In theory, a build script could be used to remove duplicate symbols (ie remove one of the SwiftProtobuf.o
files). However that's not reliable long term, since Firebase and InstantSearch could end up using different versions of SwiftProtobuf.
Thankfully I'm not using FirebaseMLModelDownloader, so may end up taking the fork approach for now at least. (If that's something you'd want as a branch on here, I could PR it, but wouldn't want to clutter branches up)
Actually, renaming the target might just solve it for your use case then. SwiftProtobuf would only be linked if you're linking the FirebaseMLModelDownloader framework. If that's the case then you wouldn't see any duplicate symbol errors.
Give this branch a try: https://github.com/akaffenberger/firebase-ios-sdk-xcframeworks/tree/namespace-collision-fix
@sejr I had a chance to test out the previously mentioned branch with InstantSearch to make sure it works, so I'm going to update the script to append a prefix to the binary targets. Once that is done you won't need a separate fork or branch.
That will prevent any name collisions going forward, however it will not fix the other use case I mentioned regarding duplicate symbols, but I will add a note about that to the README.
Hey, meant to get back to you on this, apologies. I was able to run it successfully as well. Thanks for your help!
@sejr The fix has been added with 9.1.0, feel free to update and let me know if you run into any issues. If everything is good, I will delete the namespace-collision-fix branch.
I attempted to use the approach of forking the project and commenting out the FirebaseMLModelDownloader
.
I was curious whether this fix, but it didn't work and I got the same error as @sejr.
It would be perfect to not have to fork it, is there anything I could try to overcome this issue without forking @akaffenberger?
Thank you for your work :) it's beneficial to have this repo.
Attempted to add a dependency on another library that uses SwiftProtobuf and get the following collision error:
Any thoughts on how these could be reconciled? The dependency in question is Algolia InstantSearch https://github.com/algolia/instantsearch-ios, which relies on the https://github.com/apple/swift-protobuf package.
I imagine other important dependencies may pop up with a similar issue.