简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM