appsquickly / typhoon

Powerful dependency injection for Objective-C ✨✨ (https://PILGRIM.PH is the pure Swift successor to Typhoon!!)✨✨
https://pilgrim.ph
Apache License 2.0
2.7k stars 269 forks source link

Plist activation doesn't work in Share extension #566

Open ws233 opened 7 years ago

ws233 commented 7 years ago

Hi!

It seems that plist automatic activation doesn't work in share extension, since the extension doesn't have an app delegate and the swizzled method is never being called.

Are there any plans to add a support for the Typhoon in the extensions?

Thanks!

Foboz commented 6 years ago

Hi guys! I have the same issue with iMessage extension (with storyboard + RamblerTyphoonUtils), but found the reason.

  1. Since extension don't have app delegate we should swizzle another method,( f.e. -[NSXPCListener setDelegate:]) in TyphoonStartup.m
  2. Second issue with TyphoonStoryboardResolver, that can't be used correctly because componentFactory is nil (TyphoonStoryboardResolver:42). In this case we should use dummy app delegate on the Typhoon level instead of delegate, that was swizzled in point 1 That my solution. Full solution available in my fork (https://github.com/foboz/typhoon). Maybe you can find more concise solution