108

I have trying to reduce the overall size of my iOS application which is currently 48MB. When I analyze sub folders, I found Assets.car is taking 41MB. I am not able to open and see which one is taking that much space.

I couldn't find any good documentation regarding Assets.car file. Can someone suggest how to view the contents?

hypercrypt
  • 15,389
  • 6
  • 48
  • 59
Rajeev
  • 4,762
  • 8
  • 41
  • 63
  • possible duplicate of [What is Assets.car file in .app?](http://stackoverflow.com/questions/20777488/what-is-assets-car-file-in-app) – borrrden Mar 25 '14 at 10:01
  • @borrrden, this doesn't answer my question. I am looking for analyzing which part is taking more memory. – Rajeev Mar 25 '14 at 11:49
  • @rajeevprasanna i think this file contains upscaled images for iphone 6 too! – João Nunes Oct 11 '14 at 12:58

7 Answers7

120

Run Apple’s assetutil:

xcrun --sdk iphoneos assetutil --info Assets.car

you’ll get a JSON description of each item in the file. Something like this:

  {
    "Height" : 60,
    "Scale" : 1,
    "RenditionName" : "D3801CE9-19F1-4CE9-97C6-7E1EFFFCAE89",
    "AssetType" : "Vector",
    "SizeOnDisk" : 10822,
    "Name" : "mailbox",
    "Idiom" : "universal",
    "Width" : 99
  },

Note the line "SizeOnDisk" : 10822.

This tool performs limited .car manipulation, run man assetutil for details.


The Assets.car seems to be a proprietary Apple’s archive that first appeared in iOS 7. A few utilities are able to extract its contents using the private class CUICatalog of the CoreUI framework:

There is also an app that reads .car files: crunch 9$, 15 day trial

Running strings Assets.car returned

@(#)PROGRAM:CoreUI  PROJECT:CoreUI-475.1.1
IBCocoaTouchImageCatalogTool-9.0

Running find inside Xcode-beta returned /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Overlays/IBCocoaTouchImageCatalogTool, which is a simulator executable (i386 + x86_64). Didn’t investigate any further but I bet that this tool could open .car archives if you run it inside the simulator.

Jano
  • 62,815
  • 21
  • 164
  • 192
109

This tool can extract a .car archive: https://github.com/steventroughtonsmith/cartool

Steps to extract archive:

Once you've downloaded the zip from github, compile it in Xcode to generate the command line tool. Then expand the Products group and right click on the cartool file and locate it in finder. You can then run the tool like so:

  • open terminal
  • cd /path/to/cartool
  • ./cartool /path/to/Assets.car /path/to/outputDirectory
lewis
  • 2,936
  • 2
  • 37
  • 72
  • 1
    I downloaded this tool but I don't know how to use it? Where is the output files? – jimmy May 05 '15 at 02:55
  • I've added some extra info to the answer with brief running instructions. Maybe if you get it working you could update the readme.md for other people in your shoes. – lewis May 05 '15 at 06:55
  • I do following your instruction but it said: cartool: cannot execute binary file. Please advice. Thanks. – jimmy May 08 '15 at 02:28
  • I found it. Need to run with this command ./cartool Assets.car outputDirectory. Many thanks Lewis42. – jimmy May 08 '15 at 03:00
  • ./cartool /Users/way1/Desktop/Assets.car /Users/way1/Desktop/Image\ assests -bash: ./cartool: is a directory ... can you help me in this it was showing cartool is a directory... – MANCHIKANTI KRISHNAKISHORE Feb 22 '16 at 05:03
  • getting error can not execute binary file, can you provide exact script ? In terminal i am at the path of cartool-master. – PJR Mar 25 '16 at 10:04
  • cartool paritoshraval$ /Users/paritoshraval/Desktop/Assets.car /Users/paritoshraval/Desktop/SwiftCodesclear -bash: /Users/paritoshraval/Desktop/Assets.car: cannot execute binary file – PJR Mar 25 '16 at 10:05
  • it crashed when i tried to use it to open .car file built by xCode, Version 8.0 beta 6 (8S201h) `Assertion failed: (tokenCount < maxCountIncludingZeroTerminator - 1), function CUIRenditionKeySetValueForAttribute, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreUI/CoreUI-366.1/CoreTheme/ThemeStorage/CUIThemeRendition_Support.m, line 228. ` – igrek Sep 01 '16 at 15:12
  • 3
    Couple of issues. 1) It lists the files contained in `Assets.car` but at the end the `output folder` is empty. 2) You rerun the command and it gives you `Segmentation fault: 11`. – Adeel Miraj Nov 22 '18 at 12:53
  • @adeel probably best to raise an issue at https://github.com/steventroughtonsmith/cartool – lewis Nov 22 '18 at 16:40
  • 10
    This tool doesn't work with newer .car files (from ios11 SDK) – Carla Camargo May 15 '19 at 17:40
89

If you want to browse and extract asset catalogs, you can also use my app Asset Catalog Tinkerer

Asset Catalog Tinkerer screenshot

Guilherme Rambo
  • 2,018
  • 17
  • 19
  • it crashed when i used release version 2.3 to open .car file built by xCode, Version 8.0 beta 6 (8S201h) `Assertion failed: (tokenCount < maxCountIncludingZeroTerminator - 1), function CUIRenditionKeySetValueForAttribute, file /BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreUI/CoreUI-366.1/CoreTheme/ThemeStorage/CUIThemeRendition_Support.m, line 228.` – igrek Sep 01 '16 at 15:09
  • @igrek Please open an issue on GitHub and include a sample file. Thanks. – Guilherme Rambo Sep 02 '16 at 21:16
  • I am sorry but this is a commercial project.. Do you believe it has anything to do with it's assets specifically? I tried the .cartool(http://stackoverflow.com/a/29468398/907692) and it has the same issue – igrek Sep 05 '16 at 13:06
  • There's probably something specific to the file which causes this problem. Without the file there's not much I can do... – Guilherme Rambo Sep 06 '16 at 20:10
  • @GuilhermeRambo I'm able to hit the exact error by trying to open Xcode 8's `Assets.car` file, located under `Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Versions/A/Resources` – Allen Zeng Sep 10 '16 at 10:58
  • @AllenZeng Thanks, I'll check it out. – Guilherme Rambo Sep 10 '16 at 17:31
  • Crashes on when opening my Xcode 8 assets.car, sadly. Running assetutil on that .car returns Two of these errors: "Unable to create unsliced image from csi bitmap data." – Alex Zavatone Oct 11 '16 at 19:56
  • Worked for me on 10.12.6 for touchbar assets in `/System/Library/CoreServices/SystemAppearance.bundle/Contents/Resources/Assets.car` - thanks! – ptim Dec 03 '17 at 05:04
  • I get the error `The document "Assets.car" could not be opened. Asset Catalog Tinkerer cannot open files in the "Compiled Xcode Catalog" format.` – Michael Innes Feb 09 '18 at 04:21
  • Awesome tool. Works 100% on a brew cask install on macos high sierra – shender Jun 15 '18 at 19:31
  • @GuilhermeRambo I am trying to get your NSAppearance tool to work, however it keeps crashing when trying to export the appearance. I can't figure out why though :-/ Could you help? – Steffen L. Sep 04 '18 at 09:09
  • If I wanted to mess with a program, and modify the Assets.car file with different, but same sized images, how can I recompile/rearchive the extracted files back to Assets.car? Or is this impossible of an endeavour without the source since I will need the nibs or the uncoupled storyboards in Xcode? – Jon Weinraub Mar 31 '20 at 20:14
  • Very nice application to open .car files – KSR Jan 09 '21 at 17:53
4

Open Assets.car

[Assets.car file]

You can try an online tool(Assets.car Asset Extractor Online), or a QLCARFiles QuickLook plugin for Mac

and to double check it use assetutil tool

xcrun --sdk iphoneos assetutil --info <path_to_Assets.car>
yoAlex5
  • 29,217
  • 8
  • 193
  • 205
2

All the prior mentioned tools do not extract PDFs correctly. Within the QLCARFiles project there's a utility called carDump that does extract files correctly.

In short:

  1. Clone the project from https://github.com/Timac/QLCARFiles
  2. Open in xcode
  3. Select the carDump scheme and build
  4. Use the cli:
mkdir output
carDump Assets.car output
ibash
  • 1,477
  • 17
  • 31
1

Guilherme Rambo said is correct, not the Lewis42.

Suppose a pdf file('a.pdf') in Asserts.car.

You will get three png files(a.png/a@2x.png/a@3x.png) if using cartool, file format had been changed.

But, if you using AssetCatalogTinkerer, you can preview the a.pdf file(no file format changed).

J.Caspar
  • 21
  • 2
  • But if you try to extract assets they are converted into PNGs, is there a way to extract them as PDF? – FarouK Jul 22 '21 at 13:48
0

Universal-binaries seem to contain multiple image resolutions for each screen-density.

Once the app is uploaded to the App Store the file-size will be less than your universal-binary, because each device will only get appropriate image densities.

You can check file-sizes here: iTunes Connect > My Apps > Your App > Activity > Your Build > App Store file-size

RhodanV5500
  • 1,087
  • 12
  • 16