Search code examples
iostyphoon

Accessing sub assembly of an assembly will generate EXC_BAD_ACCESS


Use case:

I have an ApplicationAssembly. This assembly has a property called CoreAssembly of type TyphoonAssembly. I'm using PLIST integration and have registered both Assemblies. I'm injecting the ApplicationAssembly into the Appdelegate.

Afterwads in a ViewController, I want to get an object which will be generated by CoreAssembly

    var appdelegate = UIApplication.sharedApplication().delegate as!  AppDelegate;
  tagHandler = appdelegate.assembly.coreAssembly.tagHandler() as! GoogleTagsHandler;

If I do this, I get an EXC_BAD_ACCESS


Solution

  • This seems to be a bug, we've logged it. In the meantime, as a workaround, please inject both ApplicationAssembly and CoreAssembly into your app delegate as follows:

    public dynamic func appDelegate() -> AnyObject {
        return TyphoonDefinition.withClass(AppDelegate.self) {
            (definition) in
    
            definition.injectProperty("assembly", with: self)
            definition.injectProperty("coreAssembly", with: self)
        }
    }