96

I've been going backwards in Git history to find the cause of a humongous file size change, but the only real reason I can find is the switch from Xcode 6 to Xcode 7 GM.

I've found that these are the top 10 file size contributors in an .ipa created from the Archive operation on a Release build configuration:

$ unzip -lv Roger\ Release.ipa | sort -k +3nr | head
41802768  Defl:N 16887199  60%  09-14-15 23:47  dc24cdc1  Payload/Roger.app/Frameworks/libswiftCore.dylib
41802400  Defl:N 16886076  60%  09-06-15 18:33  f939ea6a  SwiftSupport/iphoneos/libswiftCore.dylib
11184032  Defl:N  5915625  47%  09-14-15 23:48  6ceac4a2  Payload/Roger.app/Roger
 6399584  Defl:N  2670275  58%  09-14-15 23:47  0ac52d3f  Payload/Roger.app/Frameworks/libPhoneNumber_iOS.framework/libPhoneNumber_iOS
 5410384  Defl:N  2334189  57%  09-14-15 23:47  7a8cb03f  Payload/Roger.app/Frameworks/Alamofire.framework/Alamofire
 4521904  Defl:N  2292789  49%  09-14-15 23:47  95da0882  Payload/Roger.app/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit
 4731552  Defl:N  1926357  59%  09-14-15 23:48  e05337de  Payload/Roger.app/Frameworks/libswiftFoundation.dylib
 4731168  Defl:N  1925355  59%  09-06-15 18:33  19a5c3c4  SwiftSupport/iphoneos/libswiftFoundation.dylib
 2659232  Defl:N  1232897  54%  09-14-15 23:47  1a53a401  Payload/Roger.app/Frameworks/AFNetworking.framework/AFNetworking
 1196624  Defl:N   545343  54%  09-14-15 23:47  19a063cb  Payload/Roger.app/Frameworks/Bolts.framework/Bolts

By far the largest files are the two (slightly different) libswiftCore.dylib files, which total over 32 MB. In the bundle built by Xcode 6 these two files totaled only 3 MB.

So question #1 is: Why are the Swift core files there twice? (Embedded Content Contains Swift Code is set to No).

And question #2 is: What happened? Why did the Swift core size increase by 15 MB? Is this permanent?

Some additional notes:

  • This is a project that was entirely Objective-C but is now mostly Swift. The Defines Module setting is set to Yes.
  • The project uses CocoaPods with use_frameworks! set.
  • I've confirmed the actual download size from TestFlight on multiple devices and iOS versions and it's in the range 30–60 MB (presumably the difference is due to app slicing). It used to be 9 MB.
Blixt
  • 49,547
  • 13
  • 120
  • 153
  • Are you sure this is a release build ? (not containing simulator binaries) – deadbeef Sep 15 '15 at 14:43
  • It's an *Archive* build with release settings (no debug symbols, `-Os`). – Blixt Sep 15 '15 at 14:47
  • 4
    Xcode 7 uses app slicing, the download size most likely will be different, it will probably even decrease. I wouldn't worry about this. – Adam Sep 15 '15 at 15:41
  • 6
    @Adam: This isn't the case. The deployed version does vary depending on device, but so far I've seen 30 MB on iPhone 5s and **60 MB** on iPhone 6. Installation times have increased noticeably. This is definitely something to worry about when it used to be 9 MB. – Blixt Sep 15 '15 at 15:47
  • 3
    Actually the 30 vs. 60 MB difference is most likely due to the iPhone 5s being on iOS 9.1 and the iPhone 6 being on iOS 8. But even if all app users upgraded to iOS 9, 30 MB is still a very big increase from 9 MB. – Blixt Sep 15 '15 at 15:51
  • 2
    Did you deploy via TestFlight? The app thinning is done on Apple servers, so unless you install via TestFlight/iTunes, you won't be able to see the reduced size, I think. – MirekE Sep 15 '15 at 15:59
  • Yes, it was also 30-60 MB when deployed via Apple's servers. It's currently on TestFlight, which I presume represents the same bundle that gets downloaded once it's public on the App Store. – Blixt Sep 15 '15 at 16:02
  • http://stackoverflow.com/questions/32588757/after-switching-to-xcode-7-app-size-grew-from-9-mb-to-60-mb-is-there-a-fix#comment53047681_32590568 – David Rothera Sep 15 '15 at 23:22
  • 2
    After uploading to TestFlight, my app size reduced from 74MB to 9.6MB, so don't worry – Gintama Sep 20 '15 at 04:00
  • my problem is different when i create ipa file for development its size only 10 to 12 mb but when i create the ipa file for appstore it size became 100 mb ... after upload it on . appstore when it become visible , its size was only 18 Mb – Ravi Ojha May 22 '17 at 05:49

5 Answers5

27

Most likely caused by BitCode, I have seen the same growth however once deployed from the App Store the app size hasn't actually grown.

You can disable BitCode in your app and the other targets as well and you should see a shrinkage.

David Rothera
  • 427
  • 4
  • 8
  • I've confirmed the app download size from Apple TestFlight to be 30 to 60 MB instead of 9 MB. I don't think it will change once it's on the App Store since they presumably use the same distribution mechanism. I'll try disabling Bitcode. – Blixt Sep 15 '15 at 16:05
  • Disabling Bitcode and Debug Symbols in the build and publishing steps and archiving a build version still includes the exact same two `libswiftCore.dylib` files at ~40 MB each (~16 MB compressed). I haven't confirmed the entire deployment via TestFlight, but since these huge files are still part of the .ipa I doubt their contribution to file size will change. Overall size shrank by about ~10 MB, which is presumably mostly from taking out crash symbol support. – Blixt Sep 15 '15 at 16:14
  • 1
    I'm just going off personal experience, my .xcarchive's are a LOT larger now than pre-Xcode7 however the app store download is still the same size if not slightly smaller due to resource thinning etc. – David Rothera Sep 15 '15 at 23:20
  • 10
    Just looking now, the bundle from TestFlight was 33MB and for the self same build on the AppStore it is 10.5MB, this shows the thinning isn't done on TestFlight builds. – David Rothera Sep 15 '15 at 23:24
  • Okay, that's good to know. I'll run the app through to the App Store and hope for the best! – Blixt Sep 16 '15 at 00:23
  • Also noted on official doc: `Apps distributed for testing with TestFlight contain additional data, adding to the size of the app reported by iTunes Connect. This data will not be present after the app is released to the App Store.` https://developer.apple.com/library/content/qa/qa1795/_index.html#//apple_ref/doc/uid/DTS40014195-CH1-GET_SIZE_REPORT – Genki Mar 23 '17 at 22:55
19

I've been testing a lot of settings and combinations and it seems the file size of bundles created by Xcode 7 vary a lot depending on both the device and the version of iOS. Also, the TestFlight builds are now huge compared to before, but the good news is that once on the App Store there hasn't been a huge increase (although I am seeing about 1–2 MB added to the bundle size compared to before).

Here's a few samples to show variance between TestFlight, App Store and devices:

TestFlight, iPhone 5s on iOS 9.1
35.6 MB

TestFlight, iPhone 6 on iOS 8.4.1
70.1 MB

App Store
11.8 MB

The App Store size was identical on all devices I tested. I haven't tested it on iPhone 6 Plus though, it's very possible that the bundle size would be larger since it uses @3x assets.

Blixt
  • 49,547
  • 13
  • 120
  • 153
11

It is expected that the size of the swift dylibs, and your own code, will be significantly larger in the .xcarchive, and when you export for store distribution, due to the inclusion of bitcode. This additional size will not be reflected in what actually gets delivered to your users, so it should not be a problem. When you submit your app to the store, the store will process it to strip out the bitcode, and that processed version of the IPA is what your users will download.

If you do any type of export from your archive except a store export (e.g. save for ad-hoc deployment), we will locally strip out the bitcode (and even recompile your binaries from bitcode first, if you leave that option checked in the export workflow, to recreate what will happen on the store), so you can see how big your app will actually be. TestFlight will also strip bitcode for you and show you your true app size.

You should also be aware that your app's size can also be reduced via app thinning, which you can read about at https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/Introduction/Introduction.html. You will likely want to perform an ad-hoc export to see the size of each thinned variant of your app anyway.

Rick Ballard
  • 4,765
  • 2
  • 19
  • 17
7

Embedded Bitcode is the reason.

Assuming you don't want to disable ENABLE_BITCODE, you can strip the debug symbols.

See http://oguzbastemur.blogspot.com/2015/09/xcode-7-and-increaded-binary-size.html as stripping debug symbols away before embedding bitcode is one of the options you can do.

Nuray Altin
  • 1,294
  • 12
  • 19
0

We also had this problem with Swift 1.2. See How to prevent SwiftSupport libraries to be included twice for my original question about this same issue.

I am pretty sure this is a toolchain issue.

Community
  • 1
  • 1
Stefan Arentz
  • 34,311
  • 8
  • 67
  • 88