Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode 4.2 and Using a Static Library Causing Problems

Tags:

xcode

Like many others here SO, I am having issues using libraries in my XCode workspace. The idea is I have my main project (MyApp) and two libraries (lib1 and lib2) which were added to the workspace after the code was finalized.

For background, lib1 is dependent on lib2, since there are some protocols that need to be implemented in order to make use of lib2. MyApp is dependent on both. I have tried following the Apple guides, which implies what I would like to is simple. After that, I have followed pretty much every post here on SO that has come up in my searches (2 days worth of Googling), plus many other blogs and posts that claim to have solutions, many of which are XCode 3 specific.

Yet, my project does not build. I am using Xcode 4.2 on OS 10.6 (upgrading to Lion is not an option). Is there a simple tutorial to follow on how to create a library project, and use this library in an application.

I came across this answer while writing this question (where the question had the same error I had), which I will look into, but I have reached the point of copying source files over just to get a demo working.

UPDATE:

Here is list of issues that have come up. I will add more when they arise:

  • **directory not found for option '-L/Users/myhomedir/iphoneprojects/MyApp/../BLProfile/build/Release-iphoneos'**
like image 401
Mike D Avatar asked Mar 15 '12 18:03

Mike D


1 Answers

Here is how to create a static library and a project that use it.

Step 1: Create a workspace: File > New > Workspace. This is not mandatory but it helps organize the projects.

Step 2: Create a static library project: File > New > Project > Framework and Library > Cocoa Touch Static Library. Lets call it MyLib.

Step 3: Create an Application Project: File > New > Project > Application> Empty Application, or any other application template. Lets call this project MyApp. If you placed the projects in different folders, you may have to use a different path.

Now you have the following Projects in the workspace.

Project structure

Step 4: Configure the app so that it finds the .h files of the library. To do that, add the parent folder "../" and check the recursive checkbox.

Header Search Path

Step 5: Link the app to the library.

enter image description here

like image 141
sch Avatar answered Nov 03 '22 00:11

sch