Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After switching to Xcode 7, app size grew from 9 MB to 60 MB, is there a fix?

Tags:

xcode

ios

swift

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.
like image 508
Blixt Avatar asked Sep 15 '15 14:09

Blixt


People also ask

How do I see app size in XCode?

Product > Archive (you need the iOS device scheme selected here, which means you need a valid signing identity set up) Window > Organizer. Select the "Archives" tab. Select your archive, and in the header detail view, click "Estimate Size"

How do I know my iOS build size?

Build the application, get the . app file in your products folder, Reveal in finder and select the app and right click, choose "Get Info" to see the size of the application.


2 Answers

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.

like image 54
David Rothera Avatar answered Oct 15 '22 09:10

David Rothera


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.

like image 25
Blixt Avatar answered Oct 15 '22 10:10

Blixt