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 = ,
UIUserInterfaceSizeClassCompact = ,
UIUserInterfaceSizeClassRegular = ,
}; @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; @end void CGImageWriteToFile(CGImageRef image, NSString *path)
{
CFURLRef url = (__bridge CFURLRef)[NSURL fileURLWithPath:path];
CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypePNG, , 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:]; for (NSNumber *scaleFactor in @[@, @, @])
{
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 > )
{
// Create subdirectories for namespaced assets (those with names like "some/namespace/image-name")
NSArray* subdirectoryComponents = [pathComponents subarrayWithRange:NSMakeRange(, pathComponents.count - )]; NSString* subdirectoryPath = [outputDirectoryPath copy];
for (NSString* pathComponent in subdirectoryComponents)
{
subdirectoryPath = [subdirectoryPath stringByAppendingPathComponent:pathComponent];
} [[NSFileManager defaultManager] createDirectoryAtPath:subdirectoryPath
withIntermediateDirectories:YES
attributes:nil
error:&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 < )
{
printf("Usage: cartool <path to Assets.car> [outputDirectory]\n");
return -;
} exportCarFileAtPath([NSString stringWithUTF8String:argv[]], argc > ? [NSString stringWithUTF8String:argv[]] : nil);
}
return ;
}

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

cartool  <path to Assets.car> [outputDirectory]

中间用空格隔开就好

Assets.car 解压工具 cartool 使用报错 segmentation fault cartool 解决方案的更多相关文章

  1. ADB安装应用报错 Segmentation fault pm install /data...

    路径一定不能有中文…… 路径一定不能有中文…… 路径一定不能有中文…… 路径一定不能有中文…… 路径一定不能有中文……

  2. 文件压缩、解压工具类。文件压缩格式为zip

    package com.JUtils.file; import java.io.BufferedOutputStream; import java.io.File; import java.io.Fi ...

  3. Linux打包压缩解压工具

    第1章      Linux 打包压缩解压工具一.压缩.解压工具 compress/uncompress gzip/gunzip bzip2/bunzip2/ bzcat xz/unxz/ xzcat ...

  4. adb驱动安装和使用报错笔记

    adb驱动安装 adb驱动下载地址:https://adb.clockworkmod.com/ 安装时候选择一个容易记住的路径,这个很重要,因为adb驱动没有自动配置环境变量,所以实验时候将adb安装 ...

  5. VirtualBox使用报错

    VirtualBox使用报错 1.启动报错:Failed to instantiate CLSID_VirtualBox... 报错内容: Failed to instantiate CLSID_Vi ...

  6. 解压tar.gz文件报错gzip: stdin: not in gzip format解决方法

    解压tar.gz文件报错gzip: stdin: not in gzip format解决方法 在解压tar.gz文件的时候报错 1 2 3 4 5 [Sun@localhost Downloads] ...

  7. animate is not a function(zepto 使用报错)[转]

    animate is not a function(zepto 使用报错) 1.为什么使用zepto写animate报错? 因为zepto默认构建包含: Core, Ajax, Event, Form ...

  8. Windows下Git使用报错:warning:LF will be replaced by CRLF in ××××.××

    Windows下Git使用报错: warning:LF will be replaced by CRLF in ××××.××(文件名) The file will have its original ...

  9. yum源使用报错

    CentOS系统yum源使用报错:Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmforge. 服 ...

随机推荐

  1. Java 学习体系结构

    一. JavaWEB 阶段课程体系结构 java se基础学习 二 .JavaWEB 阶段课程体系结构 第一阶段:前端开发阶段 1 HTML   2 CSS JS    3JS    4 JQuery ...

  2. MySql自动备份shell

    MySql黑屏备份是每个运维工程师必备的技能,以下是MySQL自动备份脚本: #/bin/bash#This is mysql backup shell on 2019/4/28 BAKUP_DIR= ...

  3. Day053--MySQL

    MySQL安装和基本管理https://www.cnblogs.com/majj/p/9160383.html 管理员模式运行cmd 打开终端,输入mysqld,打开服务端. 打开终端,输入mysql ...

  4. Asp.netMVC模型

    Model负责在View和控制器之间进行数据的传递:用户输入的内容封装为Model对象,发给Controller:要显示的数据有Controller放到Model中,然后扔给View去显示.Contr ...

  5. Java:文件字符流和字节流的输入和输出

    最近在学习Java,所以就总结一篇文件字节流和字符流的输入和输出. 总的来说,IO流分类如下: 输入输出方向:     输入流(从外设读取到内存)和输出流(从内存输出到外设) 数据的操作方式: 字节流 ...

  6. X-pack 6.4.0 破解

    X-package 6.4.0 破解 获取x-pack-core-6.4.0.jar 下载 elasticsearch下载页面:https://www.elastic.co/downloads/ela ...

  7. DirectX11 With Windows SDK--26 计算着色器:入门

    前言 现在开始迎来所谓的高级篇了,目前计划是计算着色器部分的内容视项目情况,大概会分3-5章来讲述. DirectX11 With Windows SDK完整目录 Github项目源码 欢迎加入QQ群 ...

  8. 【Unity游戏开发】记一次解决 LuaFunction has been disposed 的bug的过程

    一.引子 RT,本篇博客记录的是马三的一次解决 LuaFunction has been disposed 的bug的全过程,事情还要从马三的自研框架 ColaFrameWork 说起.最近,马三在业 ...

  9. OCC上下文设置显示模式

    #include <AIS_InteractiveContext.hxx> 通过AIS_InteractiveContext::SetDisplayMode()函数来设置 void  Se ...

  10. HTTP深入浅出 http请求完整过程

    HTTP(HyperText Transfer Protocol)是一套计算机通过网络进行通信的规则.计算机专家设计出HTTP,使HTTP客户(如Web浏览器)能够从HTTP服务器(Web服务器)请求 ...