24

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)

Srikanth
  • 1,861
  • 17
  • 29
  • Have you reached out to Apple regarding this? – Harry J Oct 19 '22 at 23:30
  • I haven’t reached out to Apple yet. We are looking for alternate solutions(if any). – Srikanth Oct 19 '22 at 23:40
  • Yes, I just recompiled after some minor changes with v14.x and the size increased a lot. But it doesn't seem to be related to bitcode or symbols stripping. It looks like our .NIBs exploded in size plus icons… :-((( – silverdr Jul 25 '23 at 16:28

3 Answers3

22

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.

The T flag tells strip to remove Swift symbols, the other flags remove debugging and local symbols.

Steps to perform:

Once you generate an xcarchive, go to Show package Contents -> Products -> Applications -> YourAppName.app -> Show package contents. You will have YourAppName file. Run strip -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.

#!/bin/bash

yourAppName=PhonePe
appFolder="$yourAppName.app"

echo "$appFolder"
cd $appFolder

strip -rSTx $yourAppName -o $yourAppName

cd Frameworks

for d in */ ; do
    IFS='. ' read -r -a array <<< "$d"
    newname=${array[0]}1
    
    strip -rSTx $d/${array[0]} -o $d/${array[0]}
done

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.

Srikanth
  • 1,861
  • 17
  • 29
  • 1
    For our appstore build, we are still noticing a size increase of 5MB with Xcode 14 builds. Is there a similar size increase on your end, even after strip? Xcode 13 -> 248MB; Xcode 14 (without strip) -> 273MB; Xcode 14 (with strip) -> 253MB – asifmohd Oct 31 '22 at 11:39
  • Yes, we also have similar 4-5MB of difference @asifmohd – Srikanth Oct 31 '22 at 15:12
  • Shouldn't Apple document something officially for app/app clip size when they are deprecating bitcode. Especially app clip, since without this step the binary is going to be rejected. – akshay1188 Nov 03 '22 at 17:27
  • This article says that the stripping will invalidate the signature - https://www.emergetools.com/blog/posts/how-xcode14-unintentionally-increases-app-size @Srikanth Were you able to submit and release the build after stripping of the symbols? Also, can I follow the below steps instead to achieve the same as suggested in the above link: Deployment Postprocessing" = "Yes" "Strip Linked Product" to "Yes" "Additional Strip Flags" to -rSTx – SandeepAggarwal Dec 19 '22 at 09:26
  • The above mentioned settings work only with the app target. If you have custom frameworks or use Cocoapods to manage your dependencies, then the script which I have mentioned above works. Regarding your question whether it will invalidate app signature, no it won’t. Please ensure that you run the script on xcarchive. – Srikanth Dec 19 '22 at 11:01
  • Awesome answer. Does the `-rSTx` flags have any impact on symbolicating crash reports? Do they hinder your ability to dSYMs? – mfaani Feb 28 '23 at 21:55
  • Thank you for your solution. I did the same for App clip target (nested inside parent .app) and its frameworks. Overall it shrunk my .ipa file by a healthy 3MB allowing me to release app clip version of app. On Xcode 13 it was small enought but xcode 14 increased it(bitcode disabled) – pawisoon Mar 10 '23 at 12:39
0

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

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings['STRIP_INSTALLED_PRODUCT'] = 'YES'
    config.build_settings['STRIP_STYLE'] = "all"
    config.build_settings['STRIPFLAGS'] = "-rSTx"
  end
end
Ramesh R C
  • 644
  • 7
  • 17
-1

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):

enter image description here

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.

weyhan
  • 703
  • 4
  • 15
  • This will just strip the symbols which are in app target, it won’t strip the Pods frameworks. – Srikanth Mar 23 '23 at 10:38
  • Pod framework should be treated different from the target binaries. For embedded 3rd party binaries like framework that need to be strip, it is fine to make build step to strip but I still maintain that the target strip settings should be in the project settings. What you are advocating is for everything to be strip from a script even if the project don't include any 3rd party binaries. – weyhan Mar 24 '23 at 07:35