When I build my simple menubar cocoa application written in Swift 4 with Xcode 9, a lot of libswift*.dylib libraries are linked/downloaded/embedded into .app bundle,into Frameworks folder as seen below:
I am only using import Cocoa
and import Foundation
in my project, and some @objc functions as selector to timer functions. I really don't think my very simple menubar app would need some 3D rendering Metal library functions or any SwiftOnoneSupport, so I would like them to be removed from the .app bundle. (Same libraries are also included in the helper app for launch at login feature, which makes even the helper app over 10 MB)
I would have thought Xcode would just copy whatever is neccessary by default actually. Some similar questions were asked here and here but I don't think there is a fulfilling and up-to-date answer to both.
What I have tried so far
I set ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
to NO
in Build Settings
. It doesn't seem to have any effect.
I set LINK_WITH_STANDARD_LIBRARIES
to NO
in Build Settings
. It ruined everything and couldn't make it build even though I tried to add some frameworks(Cocoa, Foundation) on my own under Linked Frameworks and Libraries section.
libSwiftMetal
are just Swift's overlay on the underlying framework that ships with the OS, and should therefore be fairly lightweight. For me, building a sample Cocoa app, the embedded frameworks come to 11.1MB, with 9.7MB of that being libSwiftCore + libSwiftFoundation. So unless a couple of extra MBs on top of that is a problem, I wouldn't worry about it. Though the situation will be much better once Swift reaches ABI stability in Swift 5, as then the stdlib can ship as a part of the OS. – VilloselibSwiftMetal
are included when you're not using the underlying framework, I'm not sure) – Villose