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
Nested Frameworks? #844
Comments
After some testing it looks like I do need to include |
Is this what is covered in the |
@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. |
@mdiep if all frameworks are to be included at the application level what happens if two different frameworks depend on two different versions of a dependency. Say framework |
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 |
K thanks @mdiep, my questions are answered 👍 |
This repo seem to support nested frameworks with carthage support: https://github.com/tristanhimmelman/AlamofireObjectMapper |
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
CryptoSwift
out of my Cache framework and only include it in the actual app project?I can't quite tell from the README how this is intended to work.
The text was updated successfully, but these errors were encountered: