How to add a static library to iOS project in Xcode 4

Autor: | Última modificación: 9 de noviembre de 2022 | Tiempo de Lectura: 1 minutos
Temas en este post:

Static library to iOS

After struggling for a while to include CHDataStructures to my iOS project, here’s a step by step guide that will allow you to add any static library without losing your mind.

STEP 1: Add the static library sources to a Source Tree

Go to XCode preferences and select the Source Trees tab, add a new source tree whereas the name and display name are WHATEVER_LIB_SRC and the path is the full path to the source code.

STEP 2: Add the static library project to your client project

Select your client project and form the popup menu choose Add Files to project. Select the static lib project and add. Make sure you don’t copy, just reference them. The Static Lib project should now be a subproject.

STEP 3: Make sure the library is also compiled when we build our project

We need to modify our application target. Select your application target and the Build Phases tab. Open the Target Dependencies group and add the library (libXXX.a file).
Go to the Build Settings and modify the User Header Search Paths. Double click on the value and type   $(WHATEVER_LIB_SRC). Make sure to check the recursive option.

STEP 3.a: Modify the User Header Search Paths at the project level

Select your project and go to the Build Settings and modify the User Header Search Paths. Double click on the value and type   $(WHATEVER_LIB_SRC). Make sure to select the recursive option.

STEP 4: Make sure your static lib is linked to the main exe

Select your application target and the Build Phases tab. Open the Link Binary With Libraries and add the static library.
You’re done.

[email protected]

¿Trabajo? Aprende a programar y consíguelo.

¡No te pierdas la próxima edición del Aprende a Programar desde Cero Full Stack Jr. Bootcamp!

 

Prepárate en 4 meses, aprende las últimas tecnologías y consigue trabajo desde ya. 

 

Solo en España hay más de 120.400 puestos tech sin cubrir, y con un sueldo 11.000€ por encima de la media nacional. ¡Es tu momento!

 

🗓️ Próxima edición: 13 de febrero

 

Reserva tu plaza descubre las becas disponibles.