Mobile Development 14 min read

Trip.com iOS App Launch Optimization Practices

This article details the analysis of the iOS app launch process and presents a series of practical optimization techniques—ranging from reducing dynamic libraries and dead code to binary reordering and task concurrency—that together cut Trip.com’s launch time from two seconds to under one second.

Ctrip Technology
Ctrip Technology
Ctrip Technology
Trip.com iOS App Launch Optimization Practices

Introduction

The first impression of an app is its launch speed, which is crucial for user experience; therefore we spent considerable effort optimizing the launch time of the Trip.com iOS app. This article shares our practice, starting from a detailed analysis of the launch process and then proposing overarching principles and concrete solutions.

1. App Launch Process Analysis

1.1 System Interface

Load the app executable

Load dylibs

Load the dynamic linker dyld , which recursively loads dependent libraries and performs symbol binding Rebase and Bind . Typical apps load 100‑400 dylibs, most of which are system libraries cached by the OS.

Apple introduces ASLR and Code Sign for security; without rebasing, the program cannot run.

1.2 Runtime Init

ObjC and Swift initialization via _dyld_objc_notify_register

Load categories

Invoke all +load methods in inheritance order (parent → child → category)

Execute C++ constructors marked with attribute((constructor))

1.3 UIKit Init

Instantiate UIApplication and its delegate

Start event handling and system integration

1.4 Application Init

application:willFinishLaunchingWithOptions:

application:didFinishLaunchingWithOptions:

applicationDidBecomeActive:

scene:willConnectToSession:options:

sceneWillEnterForeground:

sceneDidBecomeActive:

1.5 Initial Frame Render

The first frame involves view creation, layout, drawing, and submitting the frame to the render server. Layout calculation, image decoding, and recursive layer commits can all affect latency.

1.6 Extended

This stage corresponds to asynchronous data fetching for the UI, such as loading home‑page data from the network.

2. What Can Be Done for Each Phase

2.1 Overall Principles

Delete : Remove tasks that are not essential for launch or first‑frame rendering, deferring them via lazy loading or later triggers.

Compress : Optimize essential tasks to reduce their execution time, e.g., by improving algorithms or moving work to background threads.

2.2 Specific Solutions

2.2.1 Reduce Dynamic Libraries

Audit all dylibs and delete unused ones.

Prefer static libraries for third‑party SDKs (use CocoaPods or request static versions).

Rebuild our own SDKs as static libraries by setting MACH_O_TYPE to Static Library .

Raise the minimum iOS version to 12.2 (or 13) to rely on system‑provided Swift libraries.

2.2.2 Remove Dead Code

Analyze linkmaps or binary symbols to find and delete unused methods and classes.

Use clang or third‑party tools to deduplicate code.

Enable LLVM_LTO and appropriate GCC_OPTIMIZATION_LEVEL flags.

2.2.3 Merge Categories

Combine categories to reduce load time, though the gain is limited.

2.2.4 Delete +load Methods

Move work from +load to initialize or lazy‑load it, and use Xcode breakpoints br s -r "\+\[.+ load\]$" to locate all +load entries.

2.2.5 Optimize UIApplication Subclass

No specific work was needed for our subclass.

2.2.6 Launch Task Concurrency

Break application:didFinishLaunchingWithOptions: into independent tasks, then run non‑dependent tasks in parallel while respecting dependencies.

2.2.7 I/O Handling

Identify disk I/O during launch with Instruments → App Launch and move heavy I/O to background threads.

2.2.8 Home‑Page Data Pre‑load and Lazy‑load

Pre‑load critical assets (icons, translations) during launch using background tasks.

Lazy‑load non‑essential data after the first screen is displayed.

2.2.9 Binary Reordering

Place frequently called startup methods at the beginning of the Mach‑O using an .order file generated via -fsanitize-coverage=func,trace-pc-guard and __sanitizer_cov_trace_pc_guard . This reduces page faults from dozens to a few, saving 100‑200 ms.

2.2.10 Other General Measures

Profile long‑running tasks with Instruments, optimize them, and collaborate with third‑party SDK owners (e.g., Firebase, Google) to improve their performance.

3. Results

After applying all the above techniques, the launch time was reduced from about 2 seconds to under 1 second.

Conclusion

The optimization not only sped up launch but also deepened our understanding of the iOS startup mechanism and made our codebase more robust and high‑performance.

Team Recruitment Information

We are the Ctrip International Business R&D team, focusing on international business exploration and deepening. We pursue extreme user experience in technology. If you want to grow in an international team and achieve rapid technical progress, we welcome you. Positions are open for client, frontend, backend, data, and testing development.

Resume email: [email protected] (subject: [Name]‑[Ctrip International Business]‑[Position])

Mobile DevelopmentperformanceoptimizationiOSapp launch
Ctrip Technology
Written by

Ctrip Technology

Official Ctrip Technology account, sharing and discussing growth.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.