Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to resolve protocol type from static lib that registered from different module. #509

Open
agungpratama opened this issue May 28, 2022 · 1 comment

Comments

@agungpratama
Copy link

As titled,

So let's say I have a project that has this modularized workspace setup.

Main App Project which has dependency to StaticLib1 and FeatureA.framework
FeatureA.framework is a dynamic framework that also has dependency to StaticLib1
StaticLib1 is a static lib that is linked statically to FeatureA.framework and MainApp

StaticLib1 has a public protocol SomeProtocol
MainApp act as composition root to register SomeProtocol.self into a global container and provide the detail factory process in the resolve closure.

When calling resolve SomeProtocol.self from inside of the Main app. The factory is found without problem.

When calling resolve SomeProtocol.self from inside FeatureA.framework it fails to resolve since apparently it sees the key of SomeProtocol.self that is registered on the Main App is different with SomeProtocol.self that FeatureA.framework is trying to resolve.

I wonder if this is expected due to the nature of StaticLib1 is linked statically to both the MainApp and FeatureA.framework? If yes is there a workaround to use Swinject with this kind of project setup?

Version Swinject used: 2.8.1

Thank you in advance!

@agungpratama
Copy link
Author

Here a sample workspace that mirror the situation, pardon all the mess (default, iOS 15.4, brokenload xib from FeatureA.framework) since this is just a quick made project with all default configuration in

https://github.com/agungpratama/ExperimentSwinject

As you can see:

ISomeFeatureAService.self is a protocol declared in FeatureAAPI ( static lib )

AppContainer located in MainApp registers ISomeFeatureAService.self
ViewController located in MainApp successfully resolves ISomeFeatureAService.self

FeatureAViewController located in FeatureA.framework (dynamic framework) failed to resolve ISomeFeatureAService.self

Press the button on the ViewController (first screen after launched) to present FeatureAViewController

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant