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

[TyphoonStartup swizzleSetDelegateMethodOnApplicationClass] throws exception if appDelegate is set to nil #528

Closed mchamler closed 7 years ago

mchamler commented 8 years ago

2016-09-01 19:06:40.478 MyApp[28681:1247856] [ACT]:[LOGMANAGERIMPL]:[Error]:Caught unhandled exception name=NSInternalInconsistencyException, reason=(null) is not class or protocol, stackTrace=( 0 CoreFoundation 0x0000000112dc9d85 exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001125c4deb objc_exception_throw + 48 2 CoreFoundation 0x0000000112dc9cbd +[NSException raise:format:] + 205 3 MyApp 0x000000010ed331f8 -[TyphoonComponentFactory(InstanceBuilder) allDefinitionsForType:includeSubclasses:] + 184 4 MyApp 0x000000010ed32e69 -[TyphoonComponentFactory(InstanceBuilder) definitionForType:orNil:includeSubclasses:] + 121 5 MyApp 0x000000010ed34fbb -[TyphoonComponentFactory inject:] + 171 6 MyApp 0x000000010ed524a7 +[TyphoonStartup injectInitialFactoryIntoDelegate:] + 87 7 MyApp 0x000000010ed520f0 60+[TyphoonStartup swizzleSetDelegateMethodOnApplicationClass]_block_invoke + 304

alexgarbarev commented 8 years ago

Sorry, you faced with that. Looks like easy to fix bug. I didn't expect that there is a case when appDelegate is nil. Will be fixed in next release.

mchamler commented 8 years ago

It's actually not my code that's setting the value to nil. The ADAL library is the actual culprit: https://github.com/AzureAD/azure-activedirectory-library-for-objc/blob/dev/ADAL/src/broker/ios/ADBrokerHelper.m#L130