Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating static library for iPhone

Tags:

People also ask

What is static library in iOS?

A static linker collects compiled source code, known as object code, and library code into one executable file that is loaded into memory in its entirety at runtime. The kind of library that becomes part of an app's executable file is known as a static library.— Apple Documentation.

How do I create a static library in Xcode?

Open XCode and start a new project. Under iOS, select Library and “Cocoa Touch Static Library” say it as "staticlibrary". This will create a nice new project for us that builds a . a file.

What is static library and dynamic library in iOS?

statically linked modules are fastest to load (loading non-system dynamic frameworks is pretty expensive while system frameworks are optimized). When using static linking, all the symbols are within the same module, so the app start is fast. dynamically linked modules are slower to load, especially on iOS.


There's an open source library that I would like to use for my iPhone app. The library is written in C and compiles with Makefiles. I would like to use a static library.

If I add the .a file to my project dependencies, it works well with the simulator, but it doesn't link when targeting the iPhone SDK (certainly because the .a file is compiled for an Intel platform).

What GCC compiler flags should I use to compile a static library for the iPhone SDK? I thought that the '-arch' option would provide me with an iPhone architecture, but no luck.

Any help would be appreciated.