In objc file, I use __attribute__((constructor)) to replace +load method. The calling sequence is load -> constructor -> main at runtime.
In swift file, The solution is that get all classes that conformed to SelfAware protocol via runtime and call functions defined in SelfAware protocol before applicationDidFinishLaunching method called.And I use static let instance to do the same thing as dispatch_once.
In objc file, I use
__attribute__((constructor))
to replace+load
method. The calling sequence isload -> constructor -> main
at runtime.In swift file, The solution is that get all classes that conformed to
SelfAware
protocol via runtime and call functions defined inSelfAware
protocol beforeapplicationDidFinishLaunching
method called.And I usestatic let instance
to do the same thing asdispatch_once
.