Tutorial: How do I reduce the size of my iOS app?

Source: Internet
Author: User

This article was translated from: reducing the size of my App

Q: How can I make my program install a little bit smaller, so that the program downloads and installs faster?

A: This article collects some tips for reducing the size of the program installation package (when you first download and install the program). If this is for the upgrade program, you can read this article (reduce the size of the download required for iOS application upgrades) (this differs from how the first installation works).

  Check the application

The first is to check the. App bundle to see which files in the package occupy the most space.

Before we do any related optimizations, we need to make some tradeoffs. By trade-offs, it is possible to know where to focus the optimization. We also need to consider some of the technical shortcomings mentioned in this article, and we must consider the implications to ensure that the right decisions are made. Without a trade-off, we have no way of knowing what changes need to be made to the program.

When you first install an iOS program, you need to download the full. IPA file. (Note that this differs from the upgrade). In fact, the. IPA file is a. zip structure.

We can use this method to find out the program's. IPA file: Download the app from the App Store, then sync with iTunes on your iOS device, then view the directory: ~/music/itunes/itunes music/mobile Applications, you will be able to find the. ipa file.

When we can also construct an. IPA file by using: Xcode's archive command-the file is basically the same as the format submitted to the App Store.

  Check the. IPA file

Simply modify the suffix. ipa file to. zip and extract it using the Finder. Right-click the extracted. App bundle and select Show Package contents to view the resource files inside. By this method we can see which files occupy the largest space. Remember: The app bundle is compressed, and some files are compressed better than other files, so the effect of compression is the most important. However, in general, the largest file before compression, after compression is still the largest file. We can delete a file, then right-click in the Finder, select compression, so that you can more accurately measure the file compression effect.

  IOS APP Store related factors

Executable files that are submitted to the App Store are too dense. The side effect of encryption is that the compression effect of the executable is not as good as it was before, because encryption hides some of the details. Therefore, the. IPA file downloaded from the App Store is larger than the. IPA file from the local build.

Note: Removing long text content and table data from your code and adding it to an external file can reduce the size of the final installation package download-because these files are better compressed.

If you select one of the archived in the Organizer window and then click Estimate Size,xcode you can make an assessment of the final distributed program size. There is no consideration for iOS programs on the Mac APP store and enterprise-level deployments.

  Build Settings

Compilation options

Set optimization level in build setting to fastest, smallest [-os]; Set STRIP Debug Symbols During COPY in Build setting to Yes (Copy_phase_strip = yes) to reduce the size of the compiled binaries. The settings mentioned here are the default for the release configuration in the Xcode project.

Warning: These settings will make it difficult for your program to debug. This setting is not recommended in the general development environment build,

  Target for fewer CPUs

By default, the Xcode project is configured to optimize the specific CPU type specified by the program to generate a relative executable file. Different hardware, will run different executable code. Although this optimized program can only run on some devices, this greatly reduces the size of the executable program.

To set only specific types of CPUs, you can modify the architectures in build setting from standard $ (archs_standard) to the specific type of CPU in the list that you want to support. A valid CPU name is listed in the VALID Architectures (VALID_ARCHS) build setting. Do not modify the valid architectures settings, preferably managed by Xcode.

  Assets

Perform an integrity check on the application

Use the process described in the inspecting Your app to make a comprehensive check of the. App bundle to see what's really needed. In the program, there are often some extra files, such as the Readme, which are never used.

Stripping data out of the code

Stripping all resources (such as long strings) from your code and storing them in an external file will reduce the size of the final file download, because the files are better compressed. (Refer to the full description in iOS App Store specific considerations.) )

  Image Assets

Try to use 8-bit pictures

Using 8-bit PNG images, you can reduce the compression rate by up to 4 times times compared to 32-bit images. Since 8-bit's images support up to 256 different colors, 8-bit's images should generally be used only for a small part of the color picture. For example, grayscale images are best used with 8-bit.

Use high compression ratios for images of 32-bit

With Adobe Photoshop's save for web, you can reduce the picture size of JPEG and PNG. In Xcode, by default, Pngcrush is automatically used to compress. png images.

  Audio Assets

  Compression of audio

Refer to the audio development for games in WWDC, which describes how to effectively handle the sound. Generally speaking, we use AAC or MP3 to compress audio, and we can try to reduce the bit rate of audio. Sometimes 44.1khz sampling is not necessary, and a slightly lower bit rate will not degrade the quality of the audio.

(beyondvincent Editor: by Wang Yuping)

Tutorial: How do I reduce the size of my iOS app?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.