Comparison between an empty project archive written in Swift versus Objective-C.

Hi guys,


Today I made a comparison between an empty project archive written in Swift versus the same project written in Objective-C. For getting the app sizes I used the locally stored archive files which I have found form the Organizer by going in Finder View. The results were very surprising to me. Below are the details:

1) for the Objective-C case, the project archive size was 2,3MB

2) for the Swift case, the project archive size was 101,5MB


Is this normal ? Given this fact, should I consider converting my Swift simple projects to Objective-C ?


Thanks!

I'm not that familiar with Swift, I mostly do Objective-C programming, but my understanding is that Swift apps bundle a Swift runtime to be able to run the specific version of Swift that the app was compiled for.


This runtime will obviously increase the size of the app.

Looking at the contents of the .app "file" created by a debug build (using a default project in Xcode 7.1.1) there are the following files of intrest:


Objective-C

  • Contents/MacOS/<app> 61 KB
  • Contents/Resources/Base.lproj/MainMenu.nib 36 KB


Swift

  • Contents/MacOS/<app> 37 KB
  • Contents/Resources/Base.lproj/MainMenu.nib 36 KB
  • Contents/Frameworks/libswift*.dylib 6 MB (the Swift runtime files)


So a Swift app appears to get about 6MB of extra Swift related frameworks added to it, which isn't really that much.


I'm not sure why the archive builds differ by 99.2MB rather than 6MB - although some of this could be due to dSYM files and other meta data bundled with the app archive. The Swift build may perhaps need to bundle more data ? maybe for the Swift runtime ?

Yes, typical. But since your initial goal was to compare archive sizes, I suspect you're already aware.


Search on 'swift bloat' (use google...it's more friendly and can get in here).


Up to you to convert, just remember that Swift is only at v2.0, and has lots of growth ahead of it, so you might want to tread carefully whilst it matures.

Thanks, I agree with you all and I think my question is not correct or complete, but I've noticed this big difference since Xcode 7.1, I didn't have this issue on Xcode 6 and it's not from Bitcode, I disabled it from build settings, but still there is a big difference. Actually I'm not sure it was Xcode 7.1 or Swift 2.0 who made the difference.

Comparison between an empty project archive written in Swift versus Objective-C.
 
 
Q