3

I'm trying to learn the concept of dead-code stripping of Apple.

enter image description here

To test this behavior, I've created a simple demo using SPM. I've measured app size in 3 different scenarios:

Create a new project, then export with app thinning enabled Add Pulse & Pulse UI via SPM, but I don't import or use Pulse & Pulse UI in source code, then export the app with app thinning enabled Import Pulse & Pulse UI and use in source code, then export the app with app thinning enabled. Here is the app size & app executable file in 3 scenarios:

App size is 148 KB uncompressed, app executable file is 88KB. App size is 2,7MB uncompressed, app executable file is 2,7MB. App size is 2,7MB uncompressed, app executable file is 2,7MB.

What I've tried:

  • I'm using Xcode14 with Enable Bitcode = NO.
  • For case 2, I've run the command dwarf-dump for the dSYM file, and I saw Pulse & PulseUI still there.
  • I've followed the config strip dead code in this blog: https://www.emergetools.com/blog/posts/how-xcode14-unintentionally-increases-app-size, but no luck
  • I'm using Apple Swift version 5.7.2, latest Pulse & PulseUI on main branch, Pulse was link static to the app's executable file.
  • I've run this command: "xcrun dyld_info -exports" on terminal to check for symbols that have been stripped, and the output shows that Pulse is already stripped.

Here is my demo project: https://github.com/hoangatuan/DeadCodeStrippingExample

Expected behavior: I understand that for the 2nd scenario, since I don't import or use Pulse & Pulse UI, then when I export the app with app thinning & strip dead code enabled, the Pulse should be stripped out of the app executable file. So my expectation is the app size & app executable file in 1st scenario should be approximately equal to 2nd scenario.

Question Is this a bug or my understanding of Dead-code stripping is incorrect? Or do I miss some configuration here? Thanks in advance for your help

Hoang Anh Tuan
  • 370
  • 3
  • 9

0 Answers0