- Home /
iOS Dependency injection framework suggestions
Is anyone currently using a dependency injection framework successfully with Unity3d on iOS? If so which one?
So far I have tried Autofac and Ninject and run into problems with both.
Unitypackages of test projects attached here: http://forum.unity3d.com/threads/119909-iOS-Dependency-injection-framework-suggestions
Thanks
Answer by Banderous · Aug 30, 2012 at 12:44 PM
We are using Ninject with Unity3D on iOS just fine.
On iOS, you need to specify a custom INinjectSettings when creating your kernel, that returns 'true' for the UseReflectionBasedInjection property. Otherwise Ninject will try to use Reflection.Emit when creating objects, which will crash.
You might like to look into the testability framework we are developing for Unity, which is designed around the patterns of DI and IOC.
Awesome. I will take a look at both Ninject (with your suggestion) and testability when I have more time. Thank you!
Answer by shawn42 · May 04, 2012 at 07:35 PM
There is a DI framework for iOS called Objection.
http://objection-framework.org/
It's easy to use and well tested.
"...for Objective-C for $$anonymous$$acOS X and iOS." Am I correct in saying this won't work with Unity3d or C#? Thanks anyway.
kor, that is correct Objection is $$anonymous$$acOS X and iOS. The original question asked specifically for iOS.
Answer by eventropy · Sep 20, 2013 at 04:35 PM
Yet another alternative: https://github.com/modesttree/Zenject
Answer by kor · Sep 02, 2013 at 11:40 PM
Another contender! http://thirdmotion.github.io/strangeioc/
Your answer
![](https://koobas.hobune.stream/wayback/20220613063129im_/https://answers.unity.com/themes/thub/images/avi.jpg)