How to Create a static Library in iOS?

Nidh Apple
2 min readJan 2, 2021

Before we jump in to the topic let’s know what libraries are ?

In simple words Libraries are files that define pieces of code and data that are not a part of the Xcode target. So when we add the created Libraries to an Xcode project the compiler, linker, or binder, will copy the libraries to the target producing an object file and a stand-alone executable.

So What is a a static library ?

a static library as an archive or collection of multiple object files. Static libraries are ending with .a suffix.

Now let’s see how to create a static Library in iOS. Just follow the below steps

  1. Open Xcode

2. Select Create new Project

3. Select Static Library and tap next

Static Lib creation

4. Provide the Lib Name , tap next and save it

Creating Demo Lib Static Lib

While Compiling the project we will see the DemoLib.a , which is a static library.

Static Lib generated after compile

So now we have created a simple Static Lib. We should know how to share the static lib with other projects. We can either archive the static library and share it or we can drag and drop the demoLib project fully in to the new application. One of the most common and best technique for sharing static library is through cocoa pods. We will discuss more on this in the next topic

--

--

Nidh Apple
0 Followers

Mobile Dev :). Keep things very simple!!!