0

I'm trying to build Unity project in Xcode, it is a simple 2D project of games like Crossword,Trivia, MCQ questions... when i archive and download from Testflight the game is 2GB in size, any idea what to do or why is it so big ?

elBrøwn
  • 11
  • 3
  • I think you should first verify the app size by taking TestFlight out of the equation. Rather than uploading from Xcode to TestFlight, instead _export your app as an archive_ [(see Choose a Distribution Method and Options)](https://developer.apple.com/documentation/xcode/distributing-your-app-for-beta-testing-and-releases) and get the file size of the resulting file. If the sizes are approximately the same the problem is to do with your app **not** TestFlight. For all we know you have 1.99 GB worth of assets in your _"crossword"_ game. ;) –  May 21 '22 at 11:00
  • @MickyD did that , compressed almost 70 MB uncompressed 2 GB , I changed compression method in unity build to LZ4 and the app reduced to 180 MB , also my Unity project folder is 3.3 GB in total , with 2.6 GB for Library/Artifacts. – elBrøwn May 23 '22 at 07:03
  • _"I changed compression method in unity build to LZ4 and the app reduced to 180 MB"_ - Well you would never want to use [LZ4](https://docs.unity3d.com/Manual/BuildSettingsiOS.html) for **TEST** and/or **PROD**. –  May 23 '22 at 11:12
  • What other settings are you running with in Unity **Build Settings**? Development build? IL2CPP? –  May 23 '22 at 11:16

2 Answers2

0

NOTE: Avoid using LZMA compression since Asset Bundles "...results in smaller compressed Asset Bundles but they must be entirely decompressed before use.", Unity.


Sizing

Accurate size?

when i archive and download from Testflight the game is 2GB in size, any idea what to do or why is it so big ?

You can't just look at the archive/bundle or files downloaded from TestFlight as a means to determine the app's size because the binaries produced during these development/testing scenarios include additional files (e.g. DSYM) that won't be present in it's final form thus skewing the results.1

Apple has this to say on the subject (my emphasis):

During development, the only way to get accurate download and installation sizes for your app is to create an app size report on your Mac. However, if your app is available through the App Store or the TestFlight app, App Store Connect provides the most accurate size information. It displays the size for each variant of your app and warns you if it exceeds the limit for downloading over a mobile internet connection.1

Also don't worry too much about TestFlight as builds are still going to be larger than what appears in the AppStore.1

Apps distributed for testing with TestFlight contain additional data that an App Store build doesn’t have, so the TestFlight build is larger. This additional data isn’t included in your app when you make it available in the App Store. 1

Additionally, assuming you app gets approved, Apple will modify your submission including adding DRM and re-compressing everything. So you might have to wait to see the final size.1

However, when compared to the binary you uploaded, the final size of your app after it’s approved for the App Store may end up being slightly larger. This size increase can happen when the App Store performs additional processing on your app’s binaries, adding DRM to prevent app piracy and then re-compressing the binaries.1

How to get more accurate size information?

I think the best approach is to produce a App Size Report. Apple's website has instructions for creating the most accurate file size report for download and installation sizes.2

Here's an example (courtesy Apple):2

App Thinning Size Report for All Variants of ExampleApp

Variant: ExampleApp.ipa
Supported variant descriptors: [device: iPhone11,4, os-version: 12.0], [device: iPhone9,4, os-version: 12.0], [device: iPhone10,3, os-version: 12.0], [device: iPhone11,6, os-version: 12.0], [device: iPhone10,6, os-version: 12.0], [device: iPhone9,2, os-version: 12.0], [device: iPhone10,5, os-version: 12.0], [device: iPhone11,2, os-version: 12.0], and [device: iPhone10,2, os-version: 12.0]
App + On Demand Resources size: 6.7 MB compressed, 18.6 MB uncompressed
App size: 6.7 MB compressed, 18.6 MB uncompressed
On Demand Resources size: Zero KB compressed, Zero KB uncompressed

// Other Variants of Your App.

OP:

compressed almost 70 MB uncompressed 2 GB , I changed compression method in unity build to LZ4 and the app reduced to 180 MB

As above, development/testing outputs are not indicative of the final size on the Apple Store.

Unity folder size

OP:

...also my Unity project folder is 3.3 GB in total , with 2.6 GB for Library/Artifacts.

By "project folder", I'm assuming you mean your project's top-level folder in which Unity folders such as Assets, Packages and ProjectSettings exist. In any event, getting the size of the Unity project folder isn't helpful for essentially the same reasons - it contains files that:

a) aren't necessarily deployed

b) may be temporary (Logs)

c) for Unity-use-only such as caching (Library)

The easiest way to get the size of your Unity project is to get the size of the Assets, Packages and ProjectSettings folders and the best time to do that is when performing a fresh check-out of your project from source control.

enter image description here

Remember, only the folders highlighted in green above should be added to source control and therefore are the candidates for determining your Unity project size.3

Trimming the fat

Chose a better compression option in Unity. This will compress assets, scenes and global illumination data.

For PROD you should be using LZ4HC which offers the best compression but is slower to build.

LZ4 is the next best compression and is faster to produce making it suitable for DEV builds.

The Default option in Unity doesn't use any form of compression.

Check out App Thinning on Unity's website. Since it's a large topic, I can't really do it justice by reproducing it here.


1 "Reducing Your App’s Size", Apple

2 Create the App Size Report

3 Using external version control systems with Unity, Unity

  • as I said `Library` takes most of the size so `Assets` , `Pakcages` & `ProjectSettings` are 400 MB, also for the app size report i got `App + On Demand Resources size: 70 MB compressed, 2 GB uncompressed` . So is there anything i can do to reduce the size ? my app is 2 GB or the final build will decrease ? – elBrøwn May 23 '22 at 09:40
  • @JadElAsmar _"as I said..."_ - well no you didn't. What you actually said was _"...with 2.6 GB for Library/Artifacts"_ which is subject to interpretation. Initially I thought you meant the `Library` folder but then you went and mentioned _".../Artifacts"_ which puzzled me. In software development, files labelled as artefacts are [kinda important](https://en.wikipedia.org/wiki/Artifact_(software_development)) so it sounded like you were referring to something else, hence my callout above. Unless you are running Unity 4.2 or earlier the **Library** folder should not be considered "artefacts" –  May 23 '22 at 10:35
  • @JadElAsmar _"for the app size report i got"_ - please attach your report to your question. _"So is there anything i can do to reduce the size ?"_ - see my edit above, **Trimming the fat** –  May 23 '22 at 10:56
  • thanks for all the info, turns out the problem was the textures weren't POT so most of them are getting bigger when imported to unity "for example NPOT 200KB image will be 5MB after import" that's why the app got to 2GB while looking at the asset folder info will show only 400MB. – elBrøwn May 26 '22 at 06:43
  • @JadElAsmar so we’re back to talking about the Assets folder. So what? It has zero to do with deployed games and you **can** use NPOT anyway. Impact on memory is insignificant. https://docs.unity3d.com/2017.3/Documentation/Manual/ImportingTextures.html#TextureSizes –  May 26 '22 at 11:41
  • yes , i don't have problem with memory , the problem was with the size of the app, Unity is importing the textures and most of them are like 3MB+, after build the 2GB size is like 80% Textures right ? since most of my Assets are Texture – elBrøwn May 27 '22 at 06:46
  • i believe re-importing the Textures as POT would reduce my app size – elBrøwn May 27 '22 at 06:46
  • @JadElAsmar excellent. Let us know how you go. If that was the case don't forget you can post that as an _answer_ to your _own_ question. :) –  May 27 '22 at 08:50
0

as @MickyD explained a lot of stuff that would help, however the problem was with the assets "sprites" imported were too big, so since I had like 3k sprites, i couldn't re-import each one of them as a POT so I compressed them inside Unity by overriding for IOS

  • Max Size : 512
  • Format : RGB(A) compressed ASTC 4x4 blocks

and if the sprite lost a lot of quality I would increase the size to 2048 or try another format.

elBrøwn
  • 11
  • 3