What's the difference between `*.framework`, `*.dylib` and `*.a` libs
Asked Answered
C

1

6

I have a project, in the Framework, there have *.framework, *.dylib, *.a libs.

's the

I want to know what's them? and the difference between them.

Contrast answered 4/6, 2019 at 3:5 Comment(0)
G
15

Dynamic and static libraries

First of all, a library is a collection of resources and the code itself, compiled for one or more architectures.

Static libraries (*.a):

In the case of static libraries (*.a), the code that the app uses is copied to the generated executable file by a static linker during compilation time.

Dynamic libraries (*.dylib):

Dynamic libraries (*.dylib) are different from static libraries in the sense that they are linked with the app’s executable at runtime, but not copied into it. As a result, the executable is smaller and, because the code is loaded only when it is needed, the startup time is typically faster.

Dynamic and static frameworks:

For frameworks, we first need to understand the bundle concept (as a framework is a specific kind of a bundle). A bundle is a file directory with subdirectories inside. On iOS, bundles serve to conveniently ship related files together in one package – for instance, images, nibs, or compiled code. The system treats it as one file and you can access bundle resources without knowing its internal structure.

The library may also have additional resources: headers, localization files, images, documentation, and examples of usage. We can bundle all of this together in one bundle – and the name of this is the framework.

Static frameworks contain a static library packaged with its resources. Dynamic frameworks contain the dynamic library with its resources. In addition to that, dynamic frameworks may conveniently include different versions of the same dynamic library in the same framework!

Other useful references:

Hackernoon

Runtastic

Static library

Software framework

Update:

Thanks for accepting my answer!

Compiled for one or more architectures?

Every architecture requires a different binary, and when you build an app Xcode will build the correct architecture for whatever you’re currently working with. For instance, if you’ve asked it to run in the simulator, then it’ll only build the i386 version (or x86_64 for 64-bit).

This means that builds are as fast as they can be. When you archive an app or build in release mode, then Xcode will build for all three ARM architectures, thus allowing the app to run on most devices. What about the other builds though?

Naturally, when you build your framework, you’ll want developers to be able to use it for all possible architectures, right? Of course you do since that’ll mean you can earn the respect and admiration of your peers.

Therefore you need to make Xcode build for all five architectures. This process creates a so-called fat binary, which contains a slice for each of the architectures.

arm7: Used in the oldest iOS 7-supporting devices
arm7s: As used in iPhone 5 and 5C
arm64: For the 64-bit ARM processor in iPhone 5S
i386: For the 32-bit simulator
x86_64: Used in 64-bit simulator

Raywenderlich: Multi-Architecture

Goniometer answered 4/6, 2019 at 5:51 Comment(1)
can you explain more about: compiled for one or more architectures.?Contrast

© 2022 - 2024 — McMap. All rights reserved.