1  cartool 下载地址 https://github.com/steventroughtonsmith/cartool

由于在macOS Mojave系统上 之前代码会报错需要修改main.m中的代码修改如下图 参考地址 https://github.com/steventroughtonsmith/cartool/pull/26/commits/93c1cedd304bb4b4ad987bb1be10e453536b9300

main.m修改后的代码

//
//  main.m
//  cartool
//
//  Created by Steven Troughton-Smith on 14/07/2013.
//  Copyright (c) 2013 High Caffeine Content. All rights reserved.
//

#import <Foundation/Foundation.h>typedef enum _kCoreThemeIdiom {kCoreThemeIdiomUniversal,kCoreThemeIdiomPhone,kCoreThemeIdiomPad,kCoreThemeIdiomTV,kCoreThemeIdiomCar,kCoreThemeIdiomWatch,kCoreThemeIdiomMarketing
} kCoreThemeIdiom;typedef NS_ENUM(NSInteger, UIUserInterfaceSizeClass) {UIUserInterfaceSizeClassUnspecified = 0,UIUserInterfaceSizeClassCompact     = 1,UIUserInterfaceSizeClassRegular     = 2,
};@interface CUICommonAssetStorage : NSObject-(NSArray *)allAssetKeys;
-(NSArray *)allRenditionNames;-(id)initWithPath:(NSString *)p;-(NSString *)versionString;@end@interface CUINamedImage : NSObject@property(readonly) CGSize size;
@property(readonly) CGFloat scale;
@property(readonly) kCoreThemeIdiom idiom;
@property(readonly) UIUserInterfaceSizeClass sizeClassHorizontal;
@property(readonly) UIUserInterfaceSizeClass sizeClassVertical;-(CGImageRef)image;@end@interface CUIRenditionKey : NSObject
@end@interface CUIThemeFacet : NSObject+(CUIThemeFacet *)themeWithContentsOfURL:(NSURL *)u error:(NSError **)e;@end@interface CUICatalog : NSObject@property(readonly) bool isVectorBased;
-(id)initWithURL:(NSURL *)URL error:(NSError **)error;
-(id)initWithName:(NSString *)n fromBundle:(NSBundle *)b;
-(id)allKeys;
-(id)allImageNames;
-(CUINamedImage *)imageWithName:(NSString *)n scaleFactor:(CGFloat)s;
-(CUINamedImage *)imageWithName:(NSString *)n scaleFactor:(CGFloat)s deviceIdiom:(int)idiom;
-(NSArray *)imagesWithName:(NSString *)n;@endvoid CGImageWriteToFile(CGImageRef image, NSString *path)
{CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:path];CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypePNG, 1, NULL);CGImageDestinationAddImage(destination, image, nil);if (!CGImageDestinationFinalize(destination)) {NSLog(@"Failed to write image to %@", path);}CFRelease(destination);
}NSString *idiomSuffixForCoreThemeIdiom(kCoreThemeIdiom idiom)
{switch (idiom) {case kCoreThemeIdiomUniversal:return @"";break;case kCoreThemeIdiomPhone:return @"~iphone";break;case kCoreThemeIdiomPad:return @"~ipad";break;case kCoreThemeIdiomTV:return @"~tv";break;case kCoreThemeIdiomCar:return @"~carplay";break;case kCoreThemeIdiomWatch:return @"~watch";break;case kCoreThemeIdiomMarketing:return @"~marketing";break;default:break;}return @"";
}NSString *sizeClassSuffixForSizeClass(UIUserInterfaceSizeClass sizeClass)
{switch (sizeClass){case UIUserInterfaceSizeClassCompact:return @"C";break;case UIUserInterfaceSizeClassRegular:return @"R";break;default:return @"A";}
}NSMutableArray *getImagesArray(CUICatalog *catalog, NSString *key)
{NSMutableArray *images = [[NSMutableArray alloc] initWithCapacity:5];for (NSNumber *scaleFactor in @[@1, @2, @3]){CUINamedImage *image = [catalog imageWithName:key scaleFactor:scaleFactor.doubleValue];if (image && image.scale == scaleFactor.floatValue) [images addObject:image];}return images;
}void exportCarFileAtPath(NSString * carPath, NSString *outputDirectoryPath)
{NSError *error = nil;outputDirectoryPath = [outputDirectoryPath stringByExpandingTildeInPath];//    CUIThemeFacet *facet = [CUIThemeFacet themeWithContentsOfURL:[NSURL fileURLWithPath:carPath] error:&error];
//
//    CUICatalog *catalog = [[CUICatalog alloc] init];
//
//    /* Override CUICatalog to point to a file rather than a bundle */
//    [catalog setValue:facet forKey:@"_storageRef"];/* CUICommonAssetStorage won't link */CUICatalog *catalog = nil;if ([CUICatalog instancesRespondToSelector:@selector(initWithURL:error:)]) {/* If CUICatalog has the URL API (Mojave), use it. */catalog = [[CUICatalog alloc] initWithURL:[NSURL fileURLWithPath:carPath] error:&error];} else {CUIThemeFacet *facet = [CUIThemeFacet themeWithContentsOfURL:[NSURL fileURLWithPath:carPath] error:&error];catalog = [[CUICatalog alloc] init];/* Override CUICatalog to point to a file rather than a bundle */[catalog setValue:facet forKey:@"_storageRef"];}NSCAssert(!error, @"Error attempting to open asset catalog (%@): %@", carPath, error);CUICommonAssetStorage *storage = [[NSClassFromString(@"CUICommonAssetStorage") alloc] initWithPath:carPath];for (NSString *key in [storage allRenditionNames]){printf("%s\n", [key UTF8String]);NSArray* pathComponents = [key pathComponents];if (pathComponents.count > 1){// Create subdirectories for namespaced assets (those with names like "some/namespace/image-name")NSArray* subdirectoryComponents = [pathComponents subarrayWithRange:NSMakeRange(0, pathComponents.count - 1)];NSString* subdirectoryPath = [outputDirectoryPath copy];for (NSString* pathComponent in subdirectoryComponents){subdirectoryPath = [subdirectoryPath stringByAppendingPathComponent:pathComponent];}[[NSFileManager defaultManager] createDirectoryAtPath:subdirectoryPathwithIntermediateDirectories:YESattributes:nilerror:&error];}NSMutableArray *images = getImagesArray(catalog, key);for( CUINamedImage *image in images ){if( CGSizeEqualToSize(image.size, CGSizeZero) )printf("\tnil image?\n");else{CGImageRef cgImage = [image image];NSString *idiomSuffix = idiomSuffixForCoreThemeIdiom(image.idiom);NSString *sizeClassSuffix = @"";if (image.sizeClassHorizontal || image.sizeClassVertical){sizeClassSuffix = [NSString stringWithFormat:@"-%@x%@", sizeClassSuffixForSizeClass(image.sizeClassHorizontal), sizeClassSuffixForSizeClass(image.sizeClassVertical)];}NSString *scale = image.scale > 1.0 ? [NSString stringWithFormat:@"@%dx", (int)floor(image.scale)] : @"";NSString *name = [NSString stringWithFormat:@"%@%@%@%@.png", key, idiomSuffix, sizeClassSuffix, scale];printf("\t%s\n", [name UTF8String]);if( outputDirectoryPath )CGImageWriteToFile(cgImage, [outputDirectoryPath stringByAppendingPathComponent:name]);}}}
}int main(int argc, const char * argv[])
{@autoreleasepool {if (argc < 2){printf("Usage: cartool <path to Assets.car> [outputDirectory]\n");return -1;}exportCarFileAtPath([NSString stringWithUTF8String:argv[1]], argc > 2 ? [NSString stringWithUTF8String:argv[2]] : nil);}return 0;
}

使用方法 生成了可执行文件  放在usr/local/bin 下面

cartool  <path to Assets.car> [outputDirectory]

中间用空格隔开就好

转载于:https://www.cnblogs.com/ZhangShengjie/p/10497173.html

Assets.car 解压工具 cartool 使用报错 segmentation fault cartool 解决方案相关推荐

  1. Assets.car 解压工具 cartool 使用报错 segmentation fault cartool 解决方案

    Assets.car 解压工具 cartool 使用报错 segmentation fault cartool 解决方案 参考文章: (1)Assets.car 解压工具 cartool 使用报错 s ...

  2. C++ 项目实战:跨平台的文件与视频压缩解压工具的设计与实现

    C++实战:跨平台文件与视频压缩解压工具的设计与实现 一.引言(Introduction) 1.1 项目背景与目标 1.2 技术选型:C++.FFmpeg.libarchive.libzip.Qt C ...

  3. 压缩解压工具A-Zippr for Mac

    A-Zippr for Mac版是一款便捷的压缩解压工具,能轻松打开zip.RAR和其他档案,如7z.SIT.TAR和70多种不同的文件格式,并以8种常用的归档格式进行压缩.A-Zippr for M ...

  4. 【PC工具】文件压缩解压工具winrar解压缩装机必备软件,winRAR5.70免费无广告

    微信关注 "DLGG创客DIY" 设为"星标",重磅干货,第一时间送达. 今天分享一个常用的压缩解压工具winrar. 为啥要搞这个无广告版呢(废话),总之网上 ...

  5. mac 解压_Mac上哪款解压工具好用啊?

    Mac上哪款解压工具好用啊?SmartZipper for Mac软件是mac平台上的一款解压缩软件,能够用于处理比存档实用程序更多的格式,例如RAR,7z,ISO,CAB,Zip,Lzma,Tar, ...

  6. linux 下安装rar解压软件,centos下rar解压工具的安装 rar和unrar命令使用方法

    安装rar解压工具我们需要先找到rar的工具包,rar的官方下载地址如下: //www.rarsoft.com/download 找到相对应的压缩包地址 我的是centos 64位的,我需要的地址压缩 ...

  7. 【zblog】zba解压工具

    这个zblog专用文件.zba解压工具是由网友"bearxu"发布在zblog官方论坛的,原帖地址:点击进入. https://download.csdn.net/download ...

  8. linux解压工具软件,linux 安装rar解压工具

    linux中默认的tar命令用于解压压缩文件,但是tar命令不支持rar文件的解压和压缩,需要安装rar解压工具,实现rar命令解压rar压缩包. 1.下载rarlab软件wget -c https: ...

  9. Linux中压缩解压工具使用

    1.压缩原理 目前我们使用的计算机系统是使用bytes单位计量的,实际上,计算机中最小的计量单位是bits 1 byte = 8 bits 在这里插入图片描述 一个空格代表一个bit,1byte就是8 ...

  10. xz压缩解压工具的安装

    高版本的tar是可以解压xz压缩包的,假如可以,可直接跳过小节.假如不能解压压缩的话,需要安装下面的步骤安装xz的压缩解压工具. 下载的时候总会出现*.xz的文件.这个文件压缩率比较大,根据官方的说明 ...

最新文章

  1. JavaScript总结(七)
  2. Linux C编程--网络编程1--字节顺序和字节处理函数
  3. python是高级动态编程语言-python是一种跨平台、开源、免费的高级动态编程语言,对么...
  4. 驰骋工作流引擎设计系列10时效考核规则设计
  5. mysql查询时强制区分大小写
  6. 成本中心和内部订单浅析
  7. mysql配置多个域名访问吗,tomcat部署多个项目,通过域名解析访问,不同的网站...
  8. Python中span()函数的作用
  9. ES6学习笔记(对象)
  10. # 检测中英输入法_奇怪的知识点增加了 手机输入法还能做更多
  11. 面试题之浅克隆和深克隆
  12. 微博认证:黄v怎么认证?(认证技巧分享)
  13. UE4 人物运动基本设置
  14. 查看CAD图纸时怎么将文字隐藏
  15. 使用python来搭建一个简易的文件下载环境以及用droopy来实现一个文件上传环境
  16. 做工作必须将心比心——感谢译者陈浩对我们的批评
  17. PyQt5 图表 QtChart
  18. windos下快捷键给文件、文件名重命名
  19. C/C++数据结构舞伴问题
  20. HTML+CSS网页设计期末课程大作——校园篮球网页(12页) 关于运动的HTML网页设计-----篮球

热门文章

  1. C++RAII惯用法:C++资源管理的利器
  2. VXLAN配置实例(三)——VXLAN集中式双活网关
  3. Android调试神器stetho使用详解和改造
  4. es6 modules 和commonjs
  5. 关于纠正 C/C++ 之前在函输内改变 变量的一个错误想法。
  6. Hadoop大数据之Debug
  7. Android 学习心得体会
  8. MongoDB日志工作流程
  9. 如何获取屏幕分辨率呢
  10. [Yii Framework] Another method to run cron in the share space server.