在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{
}
/// 减法
- (int)SubMethodByFirst:(int)theFirst andSecond:(int)theSecond{
}
@end
bogon:~ zhangzhen$ cd /Users/zhangzhen/Library/Developer/Xcode/DerivedData/MyStaticLibraryDemo-ciwnhcsbqgclkododazbmbmt
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-ciwnhcsbqgclkododazbmbmt
bogon:Release-iphonesimulator zhangzhen$ lipo -info libMyStaticLibraryDemo.a
Architectures in the fat file: libMyStaticLibraryDemo.a are: i386 x86_64
MyStaticLibraryDemo *myLibrary=[[MyStaticLibraryDemo alloc] init];
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:
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$
本文详细介绍了在iOS开发中如何创建静态库,包括建立项目、编写功能函数、编译静态库、使用静态库及解决导入错误等问题。同时,提供了合并静态库的方法,以实现真机和模拟器的兼容调试。









6775

被折叠的 条评论
为什么被折叠?



