Apple has deprecated the usage of Bitcode and is longer accepting any submissions with Bitcode enabled apps starting from Xcode 14. We at PhonePe disabled Bitcode and uploaded the app to the App Store connect via Xcode 14 and now seeing a very high increase in the app size. Size of the app has almost doubled from 189 MB
(with Xcode 13 and Bitcode enabled) to 342 MB
with Xcode 14.
Is anyone facing similar issue or has any solution to decrease the app size?
Deprecations
Starting with Xcode 14, bitcode is no longer required for watchOS and tvOS applications, and the App Store no longer accepts bitcode
submissions from Xcode 14.Xcode no longer builds bitcode by default and generates a warning
message if a project explicitly enables bitcode: “Building with
bitcode is deprecated. Please update your project and/or target
settings to disable bitcode.” The capability to build with bitcode
will be removed in a future Xcode release. IPAs that contain bitcode
will have the bitcode stripped before being submitted to the App
Store. Debug symbols for past bitcode submissions remain available for
download. (86118779)Because bitcode is now deprecated, builds for iOS, tvOS, and watchOS
no longer include bitcode by default. (87590506)
4
Answers
Provided a fix for it. Our app size is back to normal as earlier.
So, when we have Bitcode enabled, Apple does the stripping of the symbols from our IPA and thus helps us with smaller app size. However, when we disable Bitcode, symbols are not stripped by default. There is no documentation by Apple which recommends us to strip the symbols from the binary for bitcode disabled apps. Stripping the symbols would take you back to the previous app size where things were all normal.
To strip the symbols, we can use this command.
strip -rSTx Binary -o StrippedBinary
.Steps to perform:
Once you generate an
xcarchive
, go toShow package Contents -> Products -> Applications -> YourAppName.app -> Show package contents
. You will haveYourAppName
file. Runstrip -rSTx YourAppName -o YourAppName
to strip the symbols.If you have other frameworks bundled inside your app, go to
Frameworks
folder and run the above strip command for all those framework files as well.Here is a small script I have written which will help you to do it in one shot. Please change
yourAppName
.Once the above script or stripping process is complete, you can proceed as-usual with distributing the app to App Store. Once Apple completes the processing of your build, you will see a very high reduction in the app size.
Great article Xcode 14 unintentionally increases app size, I have added the script for each of my targets Strip Binary Symbols
Also if you are using CocoaPods add below script to podfile
Strip phase should not be a custom step using script to achieve. You can turn on strip in your target Build Settings. See below screenshot (Note the highlighted settings):
Set "Strip Linked Product", which is the friendly name for the option
STRIP_INSTALLED_PRODUCT
to Yes. If you need to specify additional flag, you can set it in "Additional Strip Flags" (STRIPFLAGS
). You can also specify how much to strip by changing the option "Strip Style" (STRIP_STYLE
) but normally it should be set to "All Symbols".Note that you can also have different setting for Debug and Release build by expanding the option by clicking on the down arrow in front of the options to reviewing the sub-options. See the screenshot the two sub-options below "Strip Linked Product". Typically, you would want to keep symbols if you are building for Debug but strip for Release build. Those symbols are for debug purpose after all so it makes sense to keep them when building for Debug.
Have you tried using any other way to create a build & archive to check the size of the build, like Fastlane?