- Home /
Is there any Dependency Injection framework compatible with iOS?
There're a lot of Dependency Injection framework that might work with Mono (and Unity):
Microsoft Unity (tested - we use it on Android). The name is tricky, but it works fine.
Ninject
Autofac
Most of them depend on emit feature of Mono, that is not available on Unity for iOS. That's because on iOS everything should be ahead-of-time-compiled (AOT).
Trying to use Microsoft's DI framework, we experience errors of sort "Attempting to JIT compile method in System.Reflection.Emit.DynamicMethod.CreateDelegate". The error itself is normal, because using Emit is not possible on iOS.
The question is are there any DI frameworks around that will work with AOT on iOS? Maybe some framework that doesn't rely on emit?
Thanks.
Answer by eventropy · Sep 20, 2013 at 04:34 PM
I know this thread is old, but I believe Zenject will probably work with what you need, which you can find here: https://github.com/modesttree/Zenject