Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injecting a simple object through modularized assembly causes crash #608

Open
xrloong opened this issue Feb 3, 2020 · 0 comments
Open

Comments

@xrloong
Copy link

xrloong commented Feb 3, 2020

I've referenced document for modularized assemblies here (https://github.com/appsquickly/typhoon/wiki/Modularizing-Assemblies).

It works. But If I found it crashes in some case. I write a sample code at here: https://github.com/xrloong/Typhoon-Modularized-Assemblies

In this sample, I use two assemblies, AppAssembly and ModularAssembly. AppAssembly keeps a ModularAssembly.

  1. In AppAssembly, it defines a TyphoonDefinition for ApplicationHelper.
    This definition injects a property of type UIApplication through ModularAssembly.
    It works.
- (ApplicationHelper*) applicationHelper
{
    return [TyphoonDefinition withClass:[ApplicationHelper class] configuration:^(TyphoonDefinition *definition) {
        [definition useInitializer:@selector(initWithApplication:) parameters:^(TyphoonMethod *initializer) {
            [initializer injectParameterWith:[self.modularAssembly application]];
        }];
    }];
}
  1. In AppAssembly, it defines a TyphoonDefinition for AnotherHelper.
    This definition injects a property of type NSString through AppAssembly's method.
    It works.
- (AnotherHelper*) anotherHelper
{
    return [TyphoonDefinition withClass:[AnotherHelper class] configuration:^(TyphoonDefinition *definition) {
        [definition useInitializer:@selector(initWithName:) parameters:^(TyphoonMethod *initializer) {
            [initializer injectParameterWith:[self anotherHelperName]];
        }];
    }];
}
  1. If TyphoonDefinition for AnotherHelper. it injects NSString through [self.modularAssembly anotherHelperName].
    This definition injects a property of type NSString through ModularAssembly.
    It crashes.
- (AnotherHelper*) anotherHelper
{
    return [TyphoonDefinition withClass:[AnotherHelper class] configuration:^(TyphoonDefinition *definition) {
        [definition useInitializer:@selector(initWithName:) parameters:^(TyphoonMethod *initializer) {
            [initializer injectParameterWith:[self.modularAssembly anotherHelperName]];
        }];
    }];
}

Here is the crash log:
2020-02-03 12:41:15.065292+0800 Typhoon Modularized Assemblies[2153:1553507] Before performInject
2020-02-03 12:41:15.067238+0800 Typhoon Modularized Assemblies[2153:1553507] Before [AppAssembly inject:]
2020-02-03 12:41:15.068321+0800 Typhoon Modularized Assemblies[2153:1553507] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'No component matching id 'anotherHelperName'.'
*** First throw call stack:
(0x1956a496c 0x1953bd028 0x19559414c 0x1048a2b54 0x1048b64e0 0x1048b5e44 0x1048bb9dc 0x10488bca4 0x10488b820 0x1048bb780 0x1048a729c 0x10489fd08 0x10489fbb8 0x1048a03f4 0x1048a4870 0x1048a2b74 0x1048a2a44 0x1048b70e4 0x1048a058c 0x1048b6fa0 0x1048a81f0 0x1048a78e0 0x10489fe0c 0x1048a4244 0x1048a3190 0x1048961c0 0x10488a9e4 0x10488ab10 0x1997890f8 0x19978aef4 0x199790820 0x198f29198 0x19978c914 0x19978cc74 0x199792a60 0x10488af40 0x195498e18)
libc++abi.dylib: terminating with uncaught exception of type NSException

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant