iOS App Size Reduction at Tongcheng Travel: Methodology, Analysis, Detection Scripts, and Optimization Techniques
This article details Tongcheng Travel's comprehensive iOS app slimming process, covering background importance, size‑reduction techniques, multi‑dimensional analysis, Python‑based detection scripts, compiler LTO optimization, resource governance, platform automation, and the resulting 29% package size decrease that boosted download conversion.
The article introduces the background of the Tongcheng Travel iOS app, explaining how accumulated unused code and resources inflate the package size, negatively affecting download click‑through, installation success, and user retention. Statistics from Google I/O show that each 6 MB increase reduces download conversion by 1 %.
1. Size‑reduction methodology – The goal is to shrink the Install Size while keeping business functionality intact, aiming for the smallest OTA‑compatible package in the industry.
2. Multi‑dimensional analysis
Business governance: track usage metrics, deprecate low‑usage components, and remove dead features.
Resource governance: script‑driven extraction of all assets (png, jpg, mp3, etc.) and optimization of files larger than 50 KB.
Technology‑stack governance: consolidate native, Flutter, hybrid, RN, H5, and dynamic modules, ultimately migrating most business to H5.
Third‑party SDK governance: identify SDKs >1 MB, evaluate value, and phase out low‑impact SDKs (e.g., direct‑connect, Baidu Voice, Tencent Video, AMap).
3. Detection scripts (Python)
def getmd5(filename):
file_txt = open(filename, 'rb').read()
m = md5.new(file_txt)
return m.hexdigest()
def functions():
md5list = {}
for file in files:
if os.path.isdir(file.path):
continue
md5obj = hashlib.md5()
fd = open(file.path, 'rb')
while True:
buff = fd.read(2048)
if not buff:
break
md5obj.update(buff)
fd.close()
filemd5 = md5obj.hexdigest().lower()
if filemd5 in md5list:
md5list[filemd5].add(file.path)
else:
md5list[filemd5] = set([file.path])
for key in md5list:
if len(md5list[key]) > 1:
print(md5list[key])Additional scripts detect large resources, duplicate images using OpenCV/imagehash, and unused Flutter assets:
def matchAndDelImage(contentStr, list):
for imgPath in list[:]:
index = imgPath.find(assetPath)
imgName = imgPath[index+1:]
if re.search(imgName, contentStr):
list.remove(imgPath)4. Compiler optimization – LTO (Link‑Time Optimization) is enabled (LLVM_LTO = YES) to merge intermediate bitcode, reducing the binary by ~0.5 MB. Both Full LTO and Thin LTO modes are discussed, with configuration examples for Xcode and CocoaPods.
5. Operational governance – Automated pipelines monitor package size increments, enforce resource thresholds, and output detailed reports for iOS and Flutter components. Incremental code and resource changes are tracked per version.
6. Results – After applying the above measures, the iOS IPA size dropped from 111 MB to 78.8 MB (≈29 % reduction, 32.2 MB saved), leading to an estimated 6 % increase in download conversion and maintaining a leading position in the industry.
All scripts, configurations, and images referenced in the original article are retained in the summary for completeness.
Tongcheng Travel Technology Center
Pursue excellence, start again with Tongcheng! More technical insights to help you along your journey and make development enjoyable.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.