Create a static library in xcode 4

Source: Internet
Author: User

To ensure code confidentiality or code reuse, You Need To package existing code into a static library. This is also a benefit of a static library. Today, I am studying how to use xcode 4 to create a static library, it 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. 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. Write Method

//// //. H

# Import <Foundation/Foundation. h>

 

 

@ Interface myclass: nsobject {

 

}

 

-(INT) add :( INT) a B :( INT) B;

 

@ End

 

/// //. M

# Import "myclass. H"

 

 

@ Implementation myclass

 

-(INT) add :( INT) a B :( INT) B

{

Return (A + B );

}

 

@ End

 

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


4. ThenEdit SchemePane (product> edit scheme), change its build configurationRelease. In this way, a static library in the release mode is generated. Note that there is a difference between the static library in the release mode and the static library in the debug mode. If an error is reported when this mode is referenced and called,"Ignoring file/users/laiqiangzhuo/desktop/testlibary/liblibary. A, missing required architecture i386 in file"Error.

 

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.

 

 

 

 

 

 

 

 

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.