I have a fairly simple iOS app that depends only on two pods, Firebase and Alamofire, but I get awful startup time before any code of mine could run.
I see times like
Total pre-main time: 18.5 seconds (100.0%)
dylib loading time: 11.1 seconds (59.7%)
rebase/binding time: 366.92 milliseconds (1.9%)
ObjC setup time: 752.48 milliseconds (4.0%)
initializer time: 6.3 seconds (34.2%)
slowest intializers :
libSystem.B.dylib : 936.19 milliseconds (5.0%)
libMainThreadChecker.dylib : 1.8 seconds (9.8%)
CoreDuet : 514.37 milliseconds (2.7%)
ShimmyMobile : 2.9 seconds (15.7%)
Although the pre-main time has ranged from 2 seconds to this extreme. I am running in the simulator so that may make things a little worse?
Firebase has a lot of dependencies, i.e. when running pod install I see:
Installing Alamofire (4.9.1)
Installing Firebase (6.17.0)
Installing FirebaseAnalyticsInterop (1.5.0)
Installing FirebaseCore (6.6.2)
Installing FirebaseCoreDiagnostics (1.2.0)
Installing FirebaseCoreDiagnosticsInterop (1.2.0)
Installing FirebaseInstallations (1.1.0)
Installing FirebaseInstanceID (4.3.1)
Installing FirebaseMessaging (4.2.1)
Installing GoogleDataTransport (4.0.0)
Installing GoogleDataTransportCCTSupport (1.4.0)
Installing GoogleUtilities (6.5.1)
Installing PromisesObjC (1.2.8)
Installing Protobuf (3.11.4)
Installing nanopb (0.3.9011)
I am only using FirebaseMessaging so is there something I can do to improve my startup times? Either removing unused dependencies or using a static build (I am using Swift 5)?
I was able to solve this by first updating cocoa pods then in my podfile commenting use_frameworks and adding use_modular_headers!
Ie
# use_frameworks!
use_modular_headers!
But yes the simulator is much slower as well.