Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Swift executable size much bigger than Objective-C executable

Tags:

swift

xcode6

Executable size of Swift application is much bigger than size of Objective-C application.

For a new empty Cocoa Application project :

  • in Objective-C, after build phase, I get a 65 Kb executable
  • in Swift, after build phase, I get a 4.2 Mb executable, 66 times more !!!

If I look at the generated package, there is a lot of frameworks included :

  • libswiftAppKit.dylib, libswiftCore.dylib (3.2Mb), libswiftCoreGraphics.dylib, libswiftDarwin.dylib, libswiftDispatch.dylib, libswiftFoundation.dylib, libswiftObjectiveC.dylib, libswiftQuartzCore.dylib, libswiftSecurity.dylib

I did not find project parameters to specify to include these libraries...

How is it that Swift executables are not build the same as in Objective-C ?

Version of Xcode used : 6.1.1

like image 752
Moldrok Avatar asked Feb 26 '15 11:02

Moldrok


1 Answers

This is to be expected.

For the time being, Swift itself lives in the binary of each application built with it. This may change when Swift reaches a release that Apple is comfortable bundling with iOS, but for now it's just something we have to live with. This behavior is the reason you can build an iOS 7/8 application in Swift 1.0/1.1/1.2 and it just works when you build and run.

You can find more info on this in this article.

like image 188
Mick MacCallum Avatar answered Oct 23 '22 16:10

Mick MacCallum