Weird source code stripping behaviour

Trying to optimize build size for iOS build. As you may know that Apple add DRM for the executable file, make it less compress-able. So generally speaking, you want to keep executable as small as possible.

After checking Unity editor console log, I found that there’s quite a lot source code files NOT used in my main scene are list in
“Used Assets, sorted by uncompressed size” section. (If you’re curious, these are FSM Actions files of PlayMaker plugin)

I have set stripping level to StripByteCode, so I assume those unused code should be stripped. But I’m confused after a simple test - by removing all those unused source files and rebuild for iOS, Xcode report me that the executable file size is 0.7MB smaller!

Is this expected behaviour?


Because Unity’s API allows you to load assets at runtime from the “Project Folder” (asset database) and it also supports the use of the eval function, there is no way of predicting which assets get used and which don’t.

If I really wanted to, I could include a script in the game that can be loaded by the user given a name. Unity can’t predict what the user will type, so it has to include all assets in the build.

Because of this (when I’m making a proper build) I usually replicate the Project folder, delete all the unused assets and build it from there. I know it’s annoying, but there is no other way around it (AFAIK).

Hope this helps,