Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An iOS (or OS X) project depends on two versions of a framework

I am writing a swift framework, which depends on Alamofire v3.x. Now I want to add my framework into a project, which depends on Alamofire v2.x. I am using Carthage to manage me project. It seems not possible to add two versions of the same framework in a project. Is there a way to solve such situation?

like image 716
ukim Avatar asked Oct 19 '25 16:10

ukim


1 Answers

What you encountered is called dependency hell. Runtimes like .NET, Node etc. have solved the problem. Java, at least up to 8, will just pick the first version it finds at runtime and hope all other packages will work with it; they don't.

CocoaPods can detect dependency hell for you and error during pod install but that's it. I think Carthage does the same? Then users of your framework are stuck downgrading dependencies here and there until your framework and other dependent frameworks all use the same version of the shared dependency. As of right now, that's still the only option available to us AFAIK.

Apple did kind of solved dependency hell via Framework versioning. The framework would bundle up multiple versions of itself and when linking against the framework, the linker would record the full path (version is in the path) to the required version. But a framework bundling up multiple versions of itself was and is an incredibly silly idea and so never took off.

like image 186
enamrik Avatar answered Oct 22 '25 06:10

enamrik