Reduce app startup time by combining swift-libs

All,

When starting an app that includes swift these libs are being loaded:

*libswiftCoreGraphics.dylib *
*libswiftDispatch.dylib *
*libswiftObjectiveC.dylib*
*libswiftCore.dylib*
*libswiftDarwin.dylib*
*libswiftFoundation.dylib*

which adds considerable delay to our app startup time (compared to running
a pure objective-c codebase). Is anybody aware of a way to reduce startup
by combining these libs into a single lib for faster load time?

Kind regards

Michel

At the moment, these are provided as individual libraries because they are built as separate libraries on the command line. It's possible to build a static version of the core library with swiftc -static-stdlib on Darwin (there are still work in progress items for Linux and Foundation).

However, note that the majority of the libraries that you list are also used in a pure objective-c codebase; for example, running otool -L on Mail.app gives:

  /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
  /usr/lib/libobjc.A.dylib
  /usr/lib/libSystem.B.dylib
  /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
  /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

(Dispatch is embedded in libSystem on Darwin)

So the libraries you load are the same ones (in effect) to the ones used by your Objective-C application, in all likelihood. The difference is probably in the way that the libraries are set up and the dispatch once code is executed - which are necessary steps in bringing the Swift runtime up for your application.

Alex

···

On 17 Feb 2017, at 21:58, Michel Loenngren via swift-dev <swift-dev@swift.org> wrote:

All,

When starting an app that includes swift these libs are being loaded:

libswiftCoreGraphics.dylib
libswiftDispatch.dylib
libswiftObjectiveC.dylib
libswiftCore.dylib
libswiftDarwin.dylib
libswiftFoundation.dylib

which adds considerable delay to our app startup time (compared to running a pure objective-c codebase). Is anybody aware of a way to reduce startup by combining these libs into a single lib for faster load time?