yonaskolb / XcodeGen

A Swift command line tool for generating your Xcode project
MIT License
7.08k stars 820 forks source link

Reducing compiled asset size #1478

Open bcardarella opened 5 months ago

bcardarella commented 5 months ago

If I compile main the resulting binary is about 15.9MBs. This appears consistent with the size in this repo's Releases.

For various reasons I need to package xcodegen as a local binary but the total size of what I'm building needs to be below 8MBs. I'm wondering if there are ways to bring downt the size of xcodegen?

I used bloaty to check out the compiled binary, unfortunately the recommended -d compileunits flag won't work (missing debug info) but without that flag I get:

    FILE SIZE        VM SIZE
 --------------  --------------
  39.5%  6.26Mi  40.9%  3.35Mi    __TEXT,__text
  25.6%  4.06Mi  24.9%  2.04Mi    String Table
  22.2%  3.52Mi  21.6%  1.77Mi    Symbol Table
   3.3%   531Ki   3.2%   269Ki    Export Info
   1.4%   231Ki   1.2%   101Ki    [41 Others]
   1.1%   182Ki   1.1%  91.7Ki    __DATA,__data
   0.9%   150Ki   0.9%  72.3Ki    __TEXT,__const
   0.7%   112Ki   0.7%  56.5Ki    __TEXT,__cstring
   0.0%       0   1.3%   106Ki    __DATA,__bss
   0.5%  86.3Ki   0.5%  43.1Ki    __TEXT,__swift5_fieldmd
   0.5%  86.0Ki   0.0%       3    __DATA_CONST,__const
   0.5%  83.5Ki   0.2%  16.3Ki    __TEXT,__eh_frame
   0.5%  78.8Ki   0.5%  39.8Ki    __DATA,__objc_const
   0.5%  78.5Ki   0.4%  35.4Ki    Binding Info
   0.5%  78.0Ki   0.4%  35.0Ki    __TEXT,__unwind_info
   0.4%  71.7Ki   0.4%  35.8Ki    __TEXT,__swift5_reflstr
   0.4%  70.1Ki   0.4%  35.2Ki    Lazy Binding Info
   0.4%  66.1Ki   0.8%  66.1Ki    __DATA,__const
   0.4%  62.1Ki   0.4%  31.1Ki    __TEXT,__constg_swiftt
   0.4%  61.8Ki   0.0%       0    Code Signature
   0.3%  50.6Ki   0.3%  25.3Ki    __TEXT,__swift5_typeref
 100.0%  15.9Mi 100.0%  8.20Mi    TOTAL

Is there anything here that can be stripped out?

Lutzifer commented 2 months ago

How do you compile xcodegen?

The binary that I get on macOS using https://github.com/yonaskolb/Mint has 7MB