Building Modern Frameworks says every app has its own copy of a custom framework. Now that Xcode supports iOS frameworks, is it still true that frameworks are static libraries but just more convenient? If that's true, then why choose the static library template? Otherwise, should I convert all my required custom frameworks to static libraries once Swift supports static libraries?
3 Answers
Frameworks serve the same purpose as static and dynamic shared libraries, that is, they provide a library of routines that can be called by an application to perform a specific task. For example, the Application Kit and Foundation frameworks provide the programmatic interfaces for the Cocoa classes and methods. Frameworks offer the following advantages over static-linked libraries and other types of dynamic shared libraries:
Frameworks group related, but separate, resources together. This grouping makes it easier to install, uninstall, and locate those resources.
Frameworks can include a wider variety of resource types than libraries. For example, a framework can include any relevant header files and documentation.
Multiple versions of a framework can be included in the same bundle. This makes it possible to be backward compatible with older programs.
Only one copy of a framework’s read-only resources reside physically in-memory at any given time, regardless of how many processes are using those resources. This sharing of resources reduces the memory footprint of the system and helps improve performance.
This excerpt taken from here.

- 17,695
- 9
- 44
- 80

- 2,409
- 1
- 21
- 33
-
with swift we can't create static library the only would be creating a framework.so framework is basically collection of static and dynamic libraries but dynamic library we shouldn't use as dynamic linking is opposed to apple rules.so swift project is turned into framework it has to contain static library its quite contradicting. – Durai Amuthan.H Mar 11 '17 at 16:09
Excerpt taken from here.
How are Frameworks and Library Different from each other?
- Inversion of Control is a key part which makes a framework different from a library. When we call a method from a library we are in control, but with the framework the control is inverted, the framework calls our code. (E.g a GUI framework calls our code through the event handlers)
- A library is essentially a set of functions (well defined operations) that we can call (organized into classes). Each does some work and then returns the control to the client
- A framework embodies some abstract design with more behavior built in. In order to use it, we need to insert our behavior into various places in the framework either by subclassing or by plugging in our code. The framework code then calls our code at these points.
- A framework can also be considered as a skeleton where the application defines the meat of the operation by filling out the skeleton. The skeleton still has code to link up the parts

- 3,209
- 1
- 34
- 40
-
2Inversion of Control is frequently seen in MacOS & iOS apps, and objectivec makes delegation and class extension easy (which classes might be distributed in frameworks), but Inversion of Control is not a distinguishing factor between static libs and frameworks. – Taryn Jun 06 '17 at 02:10
-
1@Tarryn...Can you please elaborate how Inversion of Control is not a distinguishing factor? Your comment doesn't explain that. As per my experience, the difference between static lib and framework is same as what's described in the answer above, which is actually taken from another source. – Maverick Jun 08 '17 at 09:31
-
This is true: "A library is essentially a set of functions (well defined operations) that we can call." This may be true: "...(organized into classes)...", but it needn't be, a library may also provide classic function-based (non-objective) APIs. – Taryn Jun 09 '17 at 03:10
-
From Apple's documentation: Frameworks serve the same purpose as static and dynamic shared libraries, that is, they provide a library of routines that can be called by an application to perform a specific task. For example, the Application Kit and Foundation frameworks provide the programmatic interfaces for the Cocoa classes and methods. Frameworks offer the following advantages over static-linked libraries and other types of dynamic shared libraries: Frameworks group related, but separate, resources together. This grouping makes it easier to install, uninstall, and locate those resources. – Taryn Jun 09 '17 at 03:15
-
original is here: https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WhatAreFrameworks.html#//apple_ref/doc/uid/20002303-BBCEIJFI – Taryn Jun 09 '17 at 03:19
-
1Oh look, I just noticed that @dev gr 's upvoted answer also quotes Apple's documents. It's clear that the "Modern Frameworks" book defines a Framework very differently than Apple does, but this question is specific to Apple's Frameworks, so their definition should apply. – Taryn Jun 09 '17 at 03:29
-
I got your point, and of course i read @dev gr's upvoted answer before adding mine. The only issue with his answer is, it describes what a Framework is, but doesn't focus on it's difference from Statis Library which actually is the title of this question i.e. "Required Framework vs Static Library". It doesn't answer "then why choose the static library template?" part asked in question, and that's why it's not the 'Accepted' answer. I just tried to answer the original question from another source. Anyway thanks for your input. – Maverick Jun 09 '17 at 16:26
The use of dynamic frameworks is exclusively for swift from iOS 8 and later, i.e (you can't submit a build with iOS 7 and a dynamic framework)
If you want support for iOS 7 and before you can use a static library and objc
A dynamic framework and a static library are different things, a framework is a bundle where you have a directory and can include resources, views, classes, and also libraries
A static library is only executable code
Also you use the code in a static library inside your own code, in the case of a framework he use the code and handle the way it runs and what do
This link could help you http://www.knowstack.com/framework-vs-library-cocoa-ios/

- 79
- 6