Sanchit Paurush
Sanchit Paurush

Reputation: 6152

How to build a static library of an existing project in objective-c (.a file)?

I want to make .a file means static library of my project which I have made. How can I achieve this. Please provide me the the best solution, tutorial or any other links.

Thanks in advance

Upvotes: 4

Views: 5344

Answers (3)

Anil Kothari
Anil Kothari

Reputation: 7733

Here is the easiest tutorial with which i have built a static library in iphone. After building a static library you will import a .a library file and the header file .h in your new project and use them. Here is the tutorial link for making static library.

Upvotes: 1

tacos_tacos_tacos
tacos_tacos_tacos

Reputation: 10585

http://mobileorchard.com/sharing-compiled-code-building-static-libraries-in-xcode-for-the-iphone/ has a good tutorial.

Here are the basic steps:

  1. Understand that XIB/NIB/Storyboard files have to be included separately from the library
  2. Add a new target that is a static library
  3. In the build settings for that library, include all of the .h and .m files that are relevant. For example, if your app uses a set of classes to access data and another set to view that data, you may want to just include the files relevant to accessing data.
  4. Build. Use the script provided at Build fat static library (device + simulator) using Xcode and SDK 4+ so that you can use it for iPhone simulator + device.
  5. Include your library + headers + any resources in relevant project.

Upvotes: 5

pinxue
pinxue

Reputation: 1746

With xcode4.2, easiest way is to new project, iOS/Framework & Library, CocoaTouch Static Library, and add all you files existed.

Upvotes: 2

Related Questions