Q: How can I make my program installation package smaller and make the program download and installation faster? A: This article collects some tips on reducing the size of the app installation package (when downloading and installing the program for the first time). If you are upgrading the program, you can refer to this article (Reducing the size of the iOS app upgrade download) (this works differently from the first installation).
Check the application The first thing to do is to check the .app bundle to see which files in the package take up the most space. Before making any relevant optimizations, we need to make some trade-offs. By making trade-offs, we can know where to focus the optimization. We also need to consider some of the technical shortcomings mentioned in this article. We must consider the relevant impacts to ensure that we make the right decision. If we don't make trade-offs, we won't know what changes we need to make to the program. When you first install an iOS app, you need to download a complete .ipa file. (Note that this is different from upgrading.) In fact, the .ipa file is a .zip structure. We can find the .ipa file of the program in this way: download the application from the App Store, then use iTunes to synchronize the iOS device, and then check the directory: ~/Music/iTunes/iTunes Music/Mobile Applications, and you can find the .ipa file. Of course, we can also use Xcode's Archive command to construct an .ipa file, which is basically the same format as submitted to the App Store. Check the .ipa file Simply change the .ipa file extension to .zip, and then extract it using Finder. Right-click the extracted .app bundle and select Show Package Contents to view the resource files inside. This method allows us to see which files take up the most space. Remember: .app bundles are compressed, and some files compress better than others, so the compression effect is the most important. However, in general, the largest file before compression will still be the largest file after compression. We can delete a file, then right-click it in Finder and select Compress, which will allow us to measure the file compression effect more accurately. iOS App Store Related Factors The executable file in the app submitted to the App Store is encrypted. The side effect of encryption is that the compression effect of the executable file is not as good as before, because encryption hides some details. Therefore, the size of the .ipa file downloaded from the App Store is larger than the .ipa file built locally. Note: Removing long text content and table data from the code and adding them to external files can reduce the size of the final installation package download - because these files compress better. If you select an archived in the Organizer window and click Estimate Size, Xcode can make an estimate of the size of the final distributed program. This does not take into account iOS programs on the Mac App Store and enterprise-level deployments. Build Settings Compile options Set the Optimization Level in the build setting to Fastest, Smallest [-Os]; Set the Strip Debug Symbols During Copy in the build setting to YES (COPY_PHASE_STRIP = YES) to reduce the size of the compiled binary file. These settings mentioned here are the default for the Release configuration in the Xcode project. Warning: These settings will make your program difficult to debug. It is not recommended to set them in a general development environment build. Target fewer CPUs By default, Xcode projects are configured to optimize for the specific CPU type specified by the program to generate executable files. Different hardware will run different executable codes. Although the optimized program can only run on certain devices, it greatly reduces the size of the executable program. To target only certain types of CPUs, modify the Architectures build setting from Standard $(ARCHS_STANDARD) to the specific type of CPU you want to support. Valid CPU names are listed in the Valid Architectures (VALID_ARCHS) build setting. Do not modify the Valid Architectures setting; it is best managed by Xcode. Assets Do a sanity check on the application Use the process described in Inspecting Your App to do a comprehensive inspection of the .app bundle to understand what is really needed. In the program, there are often some extra files included, such as readme files, which are never used. Separating data from code Separating all resources (such as long strings) from your code and storing them in external files will reduce the size of the final download because these files compress better. (See iOS App Store Specific Considerations for a full description.) Image Assets Try to use 8-bit images Using 8-bit PNG images can reduce the compression rate by 4 times compared to 32-bit images. Since 8-bit images support up to 256 different colors, 8-bit images should generally only be used for a small number of color images. For example, grayscale images are best used in 8-bit. For 32-bit images, try to use a high compression ratio You can use Adobe Photoshop's Save For Web to reduce the size of JPEG and PNG images. In Xcode, by default, pngcrush is automatically used to compress .png images. Audio Assets Audio Compression Refer to Audio Development for Games in WWDC, which introduces how to process audio effectively. Generally speaking, we should use AAC or MP3 to compress audio, and we can try to reduce the audio bit rate. Sometimes 44.1khz sampling is not necessary, and a slightly lower bit rate will not reduce the audio quality. |
<<: Skylake processors are more likely to be bent? Intel says it's not our fault
>>: If programmers don’t relieve stress, they will become mentally ill!
Google's parent company Alphabet released its...
1. Oral Industry Research 1. Overview of the dent...
During the operation of a product, there is one m...
The 100,000 refers to the monthly budget, not the...
The development momentum of new energy vehicles i...
On February 3, there were rumors in the domain na...
A Complete Guide to Business Analysis - Using Dat...
[[145198]] The future of mobile and web applicati...
Author: Wen Lele Dolly the Dinosaur Photo credit:...
First of all, green tea is a good thing. Green te...
When it comes to Alfa Romeo, everyone will think ...
A student who has just switched to information fl...
On April 19, 1882, Charles Darwin, a British natu...
"There's not even a single person in tha...
Recently, Xi'an has become a hot topic due to...