Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Nested Frameworks? #844
What is the recommended way to work with nested dependencies. For example I am working on a Caching framework that I want to use CryptoSwift within. Should I include the CryptoSwift.framework in the Xcode project file for my Cache framework? Or should I leave the
I can't quite tell from the README how this is intended to work.
After some testing it looks like I do need to include
@kng This should be what is covered in that section.
From what I understand the following is valid for framework that depend on other frameworks.
I also have a question related to this
Like you I have a framework FGAuth.framework that depends on other 2 frameworks (Alamofire and Swiftz). I have another project that depends on FGAuth as well as Alamofire and Swiftz.
A more schematic description is X (FGAuth) depends on Y and Z. W (my other project) depends explicitly on X Y (I have them in this other project's Cartfile) and Z.
X (FGAuth) Cartfile looks like this:
W's Carfile looks like this:
When I build the dependencies for for W this is what I get. I don't have any Copy Phase in X (FGAuth). I wonder why the frameworks are duplicated and how they got there. In my understanding they shouldn't be inside the FGAuth.framework bundle. I am using carthage 0.8.
The recommendation is to not nest dependencies—the dependencies should all linked and copied at the app-level.
If dependencies are nested/embedded, then they can't be versioned separately from the framework that depends on them. So if X and Y both depend on Z, Carthage needs to be able to pick a version of Z that works for both X and Y and Z needs to be included only once.
You must have a Copy Phase. Carthage isn't going to do this, and Xcode won't unless it's configured to.
Thank you for the fast answer!
@mdiep Unfortunately I didn't have a copy phase and building the W project for Archive from Carthage/Checkout indeed produced a .framework without the embedded /Frameworks directory.
There seems to be some cache somewhere because this is not the first time I witness this.
What is the section
So would one in this case make use of the Carfile.private?
I can imagine how it's pretty common to have a framework depend on another framework, say for making network request and wanting to distribute just one framework bundle.
In order not to force the network dependency on other projects, would I then put my network framework dependency in the Cartfile.private, add a Copy Phase and via "@rpath" tell my framework to load the networking framework and runtime from inside it's own bundle?
Using an example (framework=F):
This works fine for me but if I where ever to distribute the bundle of FDP I would have to give to my clients all my dependencies separately and have them copy them one by one, instead of distributing just one bundle.
I realise that this argument can be quite confusing, I hope I have explained myself to the best.
You can still use a framework from another framework—you just can't embed frameworks inside each other.
Yes, that's correct. But (a) it's a minor inconvenience and (b) it has the benefit of actually working in the general case.
Ok thank you very much. You have been super helpful.
This clears the issue for me.
However in my opinion the wording in
I would like to take the chance to thank you and all the people working on carthage for all the efforts made in the development and support. Many of my colleagues and I have been using carthage since very early on. Thanks again.
If the versions are 1.0 and 2.0, that won't work no matter what—and Carthage will protect you from it.
Carthage assumes that all dependencies use semantic versioning. A change in the major version signifies that incompatible changes were made. If you try to load 2 different versions of the same framework—whether from the application level or from inside another framework—it's undefined which will load into memory. But either way, you'll have loaded a version that's incompatible with part of your application.
If it's just a minor version requirement, Carthage will pick a version of that framework that's compatible with both requirements. So if a framework requires
referenced this issue
Dec 8, 2015
referenced this issue
Dec 20, 2015
This repo seem to support nested frameworks with carthage support: https://github.com/tristanhimmelman/AlamofireObjectMapper