Reduce the size of your 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

First, check .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). The .ipa file is actually a .zip structure.

We can find the program's files by downloading the .ipa app from the App Store, then syncing the iOS device with itunes, and then looking at the directory: ~/Music/iTunes/iTunes Music/Mobile Applications and you'll be able to locate the .ipa file.

It is also possible to construct a file by using the Archive command of the: Xcode, which is basically the same format as the file .ipa submitted to the App Store.

Check .ipaFile

Simply change the suffix to a .ipa file and .zip extract it using the Finder. Right-click the extracted .app bundle , select to 显示包内容 view the resource files inside. By this method we can see which files occupy the largest space. Remember: .app bundle is compressed, and some files compression effect than other files good, so the effect is the 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 压缩 , 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: 长文本内容 Remove and 表数据 wait from the code and add it to an external file, which reduces the size of the final installation package download-because the files are better compressed.

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

Build SettingsCompilation options

Set the build setting to Optimization Level Fastest, Smallest [-Os] ; set the build setting Strip Debug Symbols During Copy to YES (Copy_phase_strip = YES) to reduce the size of the compiled binaries. The settings mentioned here are the default for the configuration in the Xcode project Release .

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 build setting Architectures from the specific type of CPU that corresponds to the list that Standard $(ARCHS_STANDARD) you want to support. A valid CPU name is listed in Valid Architectures (VALID_ARCHS) build setting. Please do not modify the Valid Architectures settings, preferably by Xcode management.

AssetsPerform 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 AssetsTry 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, 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 AssetsCompression 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.


Reduce the size of your 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.