How to Create a static library in Xcode 4

Source: Internet
Author: User

Xcode 4CreateStatic LibraryThe detailed description is the content to be introduced in this article, mainly for the sake of code confidentiality or code reuse, and so on, we need to package the existing codeStatic Library.Static LibrarySo today we are studying how to useXcode 4CreateStatic LibraryIt is also for our project needs.

The Weibo SDK released by QQ reports an error because the static library is not packaged as unniver static libraries. So what is unniver static libraries? You can google it.

 
 
  1. http://blog.boreal-kiss.net/2011/03/15/how-to-create-universal-static-libraries-on-xcode-4/ 

The following describes how to create a static database:

1. xcode-create project-cocoa touch static libary. In this way, a static library template is successfully created. There is only one file in it, which is useless.

2. Create a class in the static library named MyClass. In this way, we get the. h and. m files.

3. Writing Method

. H

 
 
  1. #import <Foundation/Foundation.h> 
  2.  
  3. @interface MyClass : NSObject {  
  4. }  
  5. - (int)add:(int)a b:(int)b;  
  6. @end 

. M

 
 
  1. #import "MyClass.h"  
  2.  
  3. @implementation MyClass  
  4. - (int)add:(int)a b:(int)b  
  5. {  
  6.     return (a + b);  
  7. }  
  8.  
  9. @end 

The method is very simple. If you still don't understand it, don't read it below.

4. Then Edit Scheme pane (Product> Edit Scheme) and change its build configuration to Release to generate a static library in the release mode, note that there are differences between the static libraries in the release and debug modes. If an error is reported when the mode is referenced and called

 
 
  1. “ignoring file /Users/laiqiangzhuo/Desktop/TestLibary/TestLibary/libLibary.a, missing required architecture i386 in file“ 

.

5. Find the/build/Release-iphoneos/libLibary. a file in the main directory and drag it to the project where you want to use it.

6. Reference MyClass. h file in the project.

Summary: AboutXcode 4CreateStatic LibraryThe detailed description is complete. I hope you can learn this article to help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.