Assets.car 解压工具 cartool 使用报错 segmentation fault cartool 解决方案
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 解决方案的更多相关文章
- ADB安装应用报错 Segmentation fault pm install /data...
路径一定不能有中文…… 路径一定不能有中文…… 路径一定不能有中文…… 路径一定不能有中文…… 路径一定不能有中文……
- 文件压缩、解压工具类。文件压缩格式为zip
package com.JUtils.file; import java.io.BufferedOutputStream; import java.io.File; import java.io.Fi ...
- Linux打包压缩解压工具
第1章 Linux 打包压缩解压工具一.压缩.解压工具 compress/uncompress gzip/gunzip bzip2/bunzip2/ bzcat xz/unxz/ xzcat ...
- adb驱动安装和使用报错笔记
adb驱动安装 adb驱动下载地址:https://adb.clockworkmod.com/ 安装时候选择一个容易记住的路径,这个很重要,因为adb驱动没有自动配置环境变量,所以实验时候将adb安装 ...
- VirtualBox使用报错
VirtualBox使用报错 1.启动报错:Failed to instantiate CLSID_VirtualBox... 报错内容: Failed to instantiate CLSID_Vi ...
- 解压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] ...
- animate is not a function(zepto 使用报错)[转]
animate is not a function(zepto 使用报错) 1.为什么使用zepto写animate报错? 因为zepto默认构建包含: Core, Ajax, Event, Form ...
- 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 ...
- yum源使用报错
CentOS系统yum源使用报错:Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmforge. 服 ...
随机推荐
- MyBatis-Plus
一.通用SQL 1.简介:(简称 MP)是一个 MyBatis 的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发.提高效率而生. 2.定义Javabean中成员变量所使用的的类型: ...
- 【python 字符串】 字符串的相关方法(一)
将字符串首字母变为大写 -> capitalize() 方法 # 将字符串的首字母转换为大写 text = 'alet' ret = text.capitalize() print(ret) ...
- markdown生成的a标签如何在新页面打开
原始的超链接语法这样写:[超链接的名字](url) 在新窗口中打开:[超链接的名字](url?_blank) 在本窗口中打开:[超链接的名字](url?_self)默认是在本窗口中打开 但上面的说法貌 ...
- Luogu3732 [HAOI2017] 供给侧改革 【后缀数组】【线段树】【乱搞】
题目分析: 这道题我是乱搞的,因为他说$01$串是随机的. 那么我们可以猜测能够让LCP变大的地方很少.求出后缀数组之后可能让LCP变大的地方就等价于从大到小往height里动态加点同时维护这个点左右 ...
- 内网MySQL YUM源记录
#mysql yum */180 * * * * rsync -av --delete rsync://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-con ...
- Nginx-反向代理实现
Nginx 反向代理操作案例 Nginx反向代理的组件模块 upstream模块介绍->点我< http_proxy_module模块介绍->点我< 环境准备 1)四台服务器都 ...
- App自动化(2)--Python&Appium实现安卓手机九宫格解锁
九宫格作为常见的手势密码,我们在使用的时候,是从起点开始,按住不放,然后滑动手指,直到最后一个点松开手指,如果与设置的手势密码匹配,则解锁成功. 现在大多数九宫格作为一个元素存在,很难定位到每一个点. ...
- nginx 提示the "ssl" directive is deprecated, use the "listen ... ssl" directive instead
该问题是由于新版nginx采用新的方式进行监听https请求了 解决方式 在listen中改为 listen 443 ssl; 删除ssl配置 # ssl on; 完美解决: 解决完成前后的配置如下 ...
- linux 单用户密码修改
1.启动系统,并在GRUB2启动屏显时,按下e键进入编辑模式. 2.在linux16/inux/linuxef所在参数行ro更改为init=/sysroot/bin/sh 3.按Crl+x启动到she ...
- java 中使用RSA非对称性加密解密
需要引入的jar包:bcprov-jdk15on-161.jar 下载地址:https://www.bouncycastle.org/latest_releases.html //公钥加密 publi ...