静态库在真实开发中是一般需要在项目工程中边开发边调试
一、新建一个微博项目



二、新建一个计算数组个数的工具类(之后用来编译静态库)

import <Foundation/Foundation.h>
@interface ArraycoutTool : NSObject
+(NSInteger)arraycoutwith:(NSArray *)array;
@end
import "ArraycoutTool.h"
@implementation ArraycoutTool
+(NSInteger)arraycoutwith:(NSArray *)array{
return array.count;
}
@end
import "ViewController.h"
import "ArraycoutTool.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
NSArray *arr=@[@"1",@"2",@"3"];
NSLog(@"%ld",[ArraycoutTool arraycoutwith:arr]);
}
@end
command+B编译下工程报如下错

原因:引用了静态库文件类的方法,却没有将静态库导入项目中

Geneal->Linked Frameworks and Libraries添加libhlt.a进去
再command+B编译下就不会报错了。
然后就可以边开发、边调试了
三、编译静态库
1.暴漏头文件

2.让静态库Debug版本支持所有的cpu框架

3.编译静态库

command+B编译下就生成了
4.真机Debug版本生成同以前
5.版本合并略。。。。。。。。。。。。
网友评论