shalzangel
shalzangel

Reputation: 397

What are the ways to reduce bundle size on iOS?

I have some images which are huge in size and my bundle size currently is 70 MB. I think Xcode already runs the assets through png crush.

Upvotes: 3

Views: 947

Answers (4)

erkanyildiz
erkanyildiz

Reputation: 13234

  • Do not use any text images with useless effects, use UILabels instead.
  • Draw simple shapes and effects using CAShapeLayers instead of using images.
  • Use JPEGs instead of PNGs where you don't need transparency. (Actually file size depends on the image content here)
  • Use Save for Web option in PhotoShop or other tools to optimize PNG images.
  • Use sprites combined together instead of separate images.
  • Make sure you delete all unused resources.
  • Do not localize common parts of the images, localize only the different parts. (think of a background image with a small flag at the bottom for each locale. use one single bg image and separate flag images. localize flag images only, not the entire bg images with the flags.)
  • Use the same splash images for iOS7 and previous iOS versions. (You need to manually edit the JSON file in .xcassets)
  • Try using a CDN to download assets on the first launch.

In addition to images keep those in mind too:

  • Try replacing custom fonts with default system fonts if you don't need them really.
  • Use MP3 audio files instead of WAV files. (or other compressed formats)
  • Make sure you delete all unused 3rd party frameworks.

Upvotes: 5

Rob Jones
Rob Jones

Reputation: 4985

One option is to host the images on a CDN like OpenText and fetch them as part of app initialization, or whenever they are first needed. Obviously this is more coding, but projects like SDWebImage make it pretty easy:

https://github.com/rs/SDWebImage/tree/master/SDWebImage

It also gives you the flexibility to swap out those images later if you use caching headers.

Upvotes: 0

matt
matt

Reputation: 536027

It seems very unlikely that you actually need huge images. After all, the screen is not huge. Thus, the most likely form of size reduction is to reduce the physical dimensions of the images to the size you are actually going to be displaying.

This saves bandwidth when the user downloads the image, reduces the size of the app on the user's hard disk (the device), and also saves memory at the time an image is loaded. It is a vast waste of RAM to load an image that is larger than the size at which it will be displayed; after all, remember, the memory involved rises exponentially with the square of the difference.

Upvotes: 0

anuj
anuj

Reputation: 1060

You can try converting the images to jpg (if they don't have any transparent regions). Also try using http://imageoptim.com/

Upvotes: 3

Related Questions