Flutter iOS build contains unneeded architectures in libswiftXXX.dylib causing bloat


I noticed something curious when I moved a flutter iOS build to Github actions: The resulting Runner.app became much bigger. I traced the problem down to the .dylib files in Runner.app/Frameworks – they contain four architectures, whereas the Runner executable only contains one.

Is there a reasonably easy command-line way to instruct the Flutter build system to eliminate the unnecessary architectures? Failing that, can they be stripped out?

For avoidance of doubt, here’s what I’m seeing:

wffoote@PCRP:~/Downloads/Runner.app/Frameworks$ file libswiftFoundation.dylib 
libswiftFoundation.dylib: Mach-O universal binary with 4 architectures: [arm_v7:Mach-O dynamically linked shared library arm_v7] [arm_v7s] [arm64] [arm64e]
libswiftFoundation.dylib (for architecture armv7):  Mach-O dynamically linked shared library arm_v7
libswiftFoundation.dylib (for architecture armv7s): Mach-O dynamically linked shared library arm_v7s
libswiftFoundation.dylib (for architecture arm64):  Mach-O 64-bit dynamically linked shared library arm64
libswiftFoundation.dylib (for architecture arm64e): Mach-O 64-bit dynamically linked shared library arm64e
wffoote@PCRP:~/Downloads/Runner.app/Frameworks$ file ../Runner
../Runner: Mach-O 64-bit executable arm64

When I moved my build to Github Actions, the Runner.app zip file went from 20 MB to 70 MB. The old build system only had the arm64 architectures in the .dylib file.

For context: I know that this is mostly harmless in the normal course of events, because the Apple distribution system strips out this kind of stuff later in the pipeline.

The reason why I care about this (a little) is the following. I’m not distributing my app via the Apple app store — it’s freeware, and I’m not really willing to pay Apple $100/year in perpetuity to give away software. I also don’t own an iPhone. However, I do want to make the executable available to folks, on the off chance there’s someone who wants to install it, knows how to sign and package it for their phone, and doesn’t want to install a whole Flutter dev environment. Yeah, I know, the size of this audience is probably zero, but whatever — it just sort of bugs me to have a wonderful cross-platform development tool like Flutter, and not do what I can to make things available across all the platforms.

The actual app is a programmer’s calculator, so maybe the idea of someone signing it isn’t totally absurd? Though admittedly, re-building from the github source is probably easier than re-signing.

Anyway, it would mildly annoy me to distribute stupid bloat in an intermediate binary product, so I thought I’d check here if there’s a reasonable solution.

If you’re curious, the app(s) in question is/are https://jrpn.jovial.com/

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img