I've archived my app to submit it to the AppStore.
In the {AppName}.xcarchive > Products > Applications > {AppName} > Frameworks folder of my iOS app I found Realm.framework weighting 22.3 MB.
Does this count against the final size of the app ?
I was expecting only RealmSwift.framework to be in this folder.
I've installed Realm via Cocoapods.
RealmSwift.framework is based on Realm.framework, so for that reason you need both. As with Swift, dynamic linking is required. With dynamic linking your frameworks are copied into the app bundle in {AppName}.app/Frameworks. That's where you should find the frameworks.
They count like the Swift standard libraries into the final size of the app, because they need to be distributed as well.
Considering the size of the download and occupied on the device of the user, this will be actually a lot smaller. That's because Apple has introduced different mechanism as _App Thinning_ to be able to optimize the download and installation size. One of this is Slicing, where irrelevant architectures will be removed and only the one relevant architecture for the user's CPU will been kept in the app variant, which is delivered. With Bitcode they are able to do further size reductions.
@mrackwitz thanks for answering.
I doubt that Slicing and enabling Bitcode would reduce the 25MB (RealmSwift.framework + Realm.framework) to 1MB as advertised here : https://realm.io/docs/swift/latest/
How big is the Realm library?
Once your app is built for release, Realm should only add around 1MB to its size. The releases we distribute are significantly larger because they include support for the iOS and watchOS simulators, some debug symbols, and bitcode, which are all stripped by Xcode automatically when you build your app.
The dynamic Realm.framework in 0.95.2 is 27 MB. Of this, 16 MB is bitcode, and 6 MB is symbols for the simulator. The remaining 5 MB is the only part that actually ends up in your app, and that's cut in half by app slicing (since it has armv7 and arm64 symbols). Statically linking Realm.framework cuts it a bit further, but that's unfortunately not supported by Swift.
@tgoyne thanks!
@tgoyne how were you able to investigate what composed of the the framework binary ours is 27 as well but i can't figure out what the bitcode and symbols are thanks!
See how I made the measurements in https://github.com/realm/realm-cocoa/issues/4785#issuecomment-289987511
@jpsim thanks bud!
Most helpful comment
The dynamic Realm.framework in 0.95.2 is 27 MB. Of this, 16 MB is bitcode, and 6 MB is symbols for the simulator. The remaining 5 MB is the only part that actually ends up in your app, and that's cut in half by app slicing (since it has armv7 and arm64 symbols). Statically linking Realm.framework cuts it a bit further, but that's unfortunately not supported by Swift.