pmusolino / Wormholy

iOS network debugging, like a wizard 🧙‍♂️
MIT License
2.32k stars 184 forks source link

Fix #51 and remove load method referenced from objc files #52

Closed kealdishx closed 5 years ago

kealdishx commented 5 years ago

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.

Coeur commented 5 years ago

Woah, you're good, I didn't know about __attribute__((constructor)) before.

pmusolino commented 5 years ago

Thanks for this PR @iiiCeBlink! I will review it asap.