Required Framework vs Static Library

2019-04-04 03:43发布

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条回答
祖国的老花朵
2楼-- · 2019-04-04 04:12

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楼-- · 2019-04-04 04:19

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/

查看更多
狗以群分
4楼-- · 2019-04-04 04:20

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:

  1. Frameworks group related, but separate, resources together. This grouping makes it easier to install, uninstall, and locate those resources.

  2. Frameworks can include a wider variety of resource types than libraries. For example, a framework can include any relevant header files and documentation.

  3. Multiple versions of a framework can be included in the same bundle. This makes it possible to be backward compatible with older programs.

  4. 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.

查看更多
登录 后发表回答