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.
- 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
- #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. 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
- “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!