Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

ios

.a

dylib

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.

like image 608
user7693832 Avatar asked Jun 04 '19 03:06

user7693832


People also ask

What is difference between framework and static library iOS?

Libraries and frameworks are basic building blocks for creating iOS and macOS programs. Libraries are collections of code and data, while frameworks are hierarchial directories with different kinds of files, including other libraries and frameworks. Based on how libraries are linked, they can be static or dynamic.

What is DYLIB file in macOS?

A file with the DYLIB file extension is a Mach-O (Mach Object) Dynamic Library file that an application references during runtime in order to perform certain functions on an as-needed basis. The format has replaced the older A. OUT file format.

What is iOS DYLIB?

.dylib stands for dynamic library. A Static library (.a) A Static library (. a) is a pack of compiled classes, functions which can be used together with iOS app development project. It is a compiled binary or fat file and can be shared between projects.

What is difference between static and dynamic 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!


1 Answers

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

like image 148
Hitesh Surani Avatar answered Sep 20 '22 21:09

Hitesh Surani