静态库和framework的封装

http://www.cocoachina.com/bbs/read.php?tid-282490-page-1.html

注意点:

  • bundle里面不要带plist文件.build setting -> packaging->info.plist file设置为空。否则提审的时候可能会报Executable file相关的错误
  • bundle中资源的获取方法
+(NSBundle*)getResourcesBundle
{
    return  [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"JYSDK_IMAGE" ofType:@"bundle"]];
}

+ (NSBundle *)getNibBundle
{
    return  [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"JYSDK_XIB" ofType:@"bundle"]];
}

+ (UIImage *)imageWithName:(NSString *)imageName
{
    NSBundle *bundle = [self getResourcesBundle];
    return [UIImage imageWithContentsOfFile:[bundle pathForResource:imageName ofType:@"png"]];
}

+ (UIView *)loadNibViewWithName:(NSString *)nibName owner:(nullable id)owner
{
    NSBundle *bundle = [self getNibBundle];
    return [bundle loadNibNamed:nibName owner:owner options:nil].lastObject;
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容