在iOS的開發過程中,我們常常用到第三方的庫。尤其是QQ、百度地圖、廣告等。
#import
@interface MyStaticLibraryDemo : NSObject
/// 加法
- (int)addMethodByFirst:(int)theFirst andSecond:(int)theSecond;
/// 減法
- (int)SubMethodByFirst:(int)theFirst andSecond:(int)theSecond;
@end
#import "MyStaticLibraryDemo.h"
@implementation MyStaticLibraryDemo
/// 加法
- (int)addMethodByFirst:(int)theFirst andSecond:(int)theSecond{
return (theFirst+theSecond);
}
/// 減法
- (int)SubMethodByFirst:(int)theFirst andSecond:(int)theSecond{
return (theFirst-theSecond);
}
@end
bogon:~ zhangzhen$ cd /Users/zhangzhen/Library/Developer/Xcode/DerivedData/MyStaticLibraryDemo-ciwnhcsbqgclkododazbmbmtdlfp/Build/Products/Release-iphoneos
bogon:Release-iphoneos zhangzhen$ lipo -info libMyStaticLibraryDemo.a(輸入)
Architectures in the fat file: libMyStaticLibraryDemo.a are: armv7 armv7s arm64 (輸出)
bogon:~ zhangzhen$ cd /Users/zhangzhen/Library/Developer/Xcode/DerivedData/MyStaticLibraryDemo-ciwnhcsbqgclkododazbmbmtdlfp/Build/Products/Release-iphonesimulator
bogon:Release-iphonesimulator zhangzhen$ lipo -info libMyStaticLibraryDemo.a
Architectures in the fat file: libMyStaticLibraryDemo.a are: i386 x86_64
MyStaticLibraryDemo *myLibrary=[[MyStaticLibraryDemo alloc] init];
int result= [myLibrary addMethodByFirst:5 andSecond:5];
NSLog(@"Result:%d",result);
result=[myLibrary SubMethodByFirst:10 andSecond:5];
NSLog(@"Result:%d",result);
ld: warning: ignoring file /Users/XXXX/Documents/MyLibraryTest/MyLibraryTest/MyLibrary/libMyStaticLibraryDemo.a, missing required architecture i386 in file/Users/XXXX/Documents/MyLibraryTest/MyLibraryTest/MyLibrary/libMyStaticLibraryDemo.a (3 slices)
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MyStaticLibraryDemo", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
bogon:~ zhangzhen$ lipo -create /所在路徑/Release-iphoneos/libMyStaticLibraryDemo.a /所在路徑/Release-iphonesimulator/libMyStaticLibraryDemo.a -output/Users/zhangzhen/Desktop/libUniversal.a
bogon:~ zhangzhen$