laitimes

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

Feng se comes from Aofei Temple

Qubits | Official account QbitAI

A few days ago, a mobile phone QQ installation package will be fast 900MB, and there is a lot of noise on the Internet.

Although in the end, everyone found that it mainly added an Unreal Engine for video call effects, netizens still sighed:

Now the app is really getting bigger.

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

And just recently, a foreign programmer also encountered the same confusion.

He was on a plane that didn't have a small tv on board, so he could only download an app called "United" to watch videos to pass the time.

The little brother lamented that the airline is now more and more chicken thief: adding costs to the customer's head, while opening the app store, the result is very surprised:

Don't you just need to watch a movie, a Netflix is only 101.5MB, how is this app four times its size?

As an iOS/Android development engineer, the little brother decided not to "sit still" and see if it really needed such a large space.

It turns out that 187MB can be saved

When all was said and done, the brother who was still on the plane immediately downloaded the binary file of this app with ipatool.

ipatool is an open source project with star 1.4k on GitHub, which is a command-line tool that can search and download the iPA file package of the application from the iOS App Store, with this package can be used to perform some checks and other functions of the development content.

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

After the next good, you need to change the ipa extension to zip, and after decompression, you can see the following directory:

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

It can be found that the frameworks account for 414.8MB, the little brother explained: the main source of memory for the application is frameworks, and the best practices now are to put the code push into it, or quite normal.

Next go to the directory:

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

The frameworks that start with UAL are the core architecture, the NodeMobile framework is related to the NodeJS feature, the LocusLabsSDK and Mapbox are the supply maps, and some are responsible for authentication, customer feedback...

Video playback-related frameworks don't actually take up much memory:

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

Then move on to the largest footprint of the UALAppCore.framework.

After layers of exploration, the little brother finally locked in the largest UALAppCore here.

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

According to his work experience, the number 77MB is still a bit abnormal, and he intends to use the nm command to look deeply into the symbol table (symbol table of this framework (nm is used to display the symbol table of binary target files, the format is as follows).

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

It soon occurred to him that Swift's symbol needed to be stripped (strip, a term in the iOS framework) and Objective-C was not.

Then check Swift's, and the results will really be found:

None of the Swift framework symbols have been stripped away.

And these are useless, in vain to consume memory:

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

Then it is simple, write a bash script and run the framework to OK:

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

Finally, you can see that the original frame has been reduced from 350MB to 163M!

In 5 minutes, the programmer cut off an Apple installation package of more than 400MB and 187MB

The brother said that this operation took less than 5 minutes, and he did not expect that the reduction space was so large, saving 187MB.

This means that the current installation package is less than 60% of the original.

He guessed that there was still room for cuts in the installation package, but he was already satisfied with the results.

Are you a student?

"Developers don't care"

Just after the little brother issued this blog, some netizens commented that there are many installation packages that can actually reduce the space by 15% to 30% or even higher, such as Gmail, Outlook and other very common applications.

But it seems that many developers are not very concerned about this problem now, they just want to keep updating the app:

If you don't save hundreds of M of traffic for users, you can make the same money, why bother?

One embedded engineer said: When I talk to my colleagues about paying attention to this optimization, they always give me a blank look.

Some netizens believe that unless the app stores start to manage this matter, the developer will not make changes. Just to say that mobile phone manufacturers are happy to see this scene, not enough memory can go to them to buy a new mobile phone.

He also found that the Google Play Store didn't seem to show app size.

And some bank apps are especially serious about this problem because they know you won't switch banks easily.

What do you think?

Original Blog Link:

https://telkins.dev/posts/how-i-shaved-187mb-off-uniteds-airlines-439mb-ios-app/

Comments from:

https://news.ycombinator.com/item?id=30442529&p=2

Read on