Improving iOS Build Speed with cocoapods-hmap-prebuilt Plugin
The article presents Meituan’s cocoapods‑hmap‑prebuilt plugin, which creates per‑pod and shared header‑map files to replace CocoaPods’ default header search paths, eliminates duplicate headers and disables Xcode’s native map, delivering over 45 % faster builds and more than 50 % shorter packaging times in large iOS projects.
This article introduces cocoapods-hmap-prebuilt , a Meituan‑developed CocoaPods plugin that significantly speeds up iOS project compilation by leveraging Header Map technology.
Header Map is a binary mapping table that lets the compiler resolve header files via a fast in‑memory lookup instead of scanning the file system. Although Xcode provides a built‑in Header Map option, it does not work well with large CocoaPods‑based projects because of the way CocoaPods creates soft links and populates Header Search Paths.
Typical problems in a massive project (400+ pods) include:
Excessive -I options that can overflow the compiler command line.
Millions of header files causing heavy I/O during search and symlink creation.
Compilation time growing linearly with the number of components (often >1 hour for a full build).
Potential header name collisions that make later headers invisible.
Private headers becoming reachable through ${PODS_ROOT}/Headers/Private, breaking encapsulation.
The cocoapods-hmap-prebuilt plugin addresses these issues by:
Generating n+1 hmap files (one per pod plus a shared public hmap) that index all private and public headers.
Replacing the original Header Search Path entries in the xcconfig with references to the generated hmap files.
Handling duplicate public headers by storing them as PodName/Header.h keys.
Disabling the native Xcode Header Map to avoid redundant file creation.
Using the plugin only requires two steps:
/// part of Gemfile
source 'http://sakgems.sankuai.com/' do
gem 'cocoapods-hmap-prebuilt'
gem 'XXX'
...
end
// part of Podfile
target 'XXX' do
plugin 'cocoapods-hmap-prebuilt'
pod 'XXX'
...
endIn Meituan’s own iOS codebase, the plugin improves the overall build pipeline by more than 45% and reduces Xcode packaging time by over 50%.
Overall, the article demonstrates how a custom hmap generation strategy can overcome the limitations of the default CocoaPods header handling and deliver substantial build‑time gains.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Meituan Technology Team
Over 10,000 engineers powering China’s leading lifestyle services e‑commerce platform. Supporting hundreds of millions of consumers, millions of merchants across 2,000+ industries. This is the public channel for the tech teams behind Meituan, Dianping, Meituan Waimai, Meituan Select, and related services.
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.
