<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 17, 2015, at 10:54 AM, Gergely Orosz via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">As a user of swift, building projects on top of it, the single biggest limitation I've come across is that <b class="">all </b>my unit tests are significantly more bloated compared to Objective C... because mocking & stubbing is not possible due to the static nature of the language and that readwrite reflection is not supported.<div class=""><br class=""></div><div class="">I did some research and apart from C++ and C I couldn't find any other popular language that does not support readwrite reflection (here's a post I wrote on the topic: <a href="http://bit.ly/1PbgSys" class="">http://bit.ly/1PbgSys</a> ).</div><div class=""><br class=""></div><div class="">Not having readwrite reflection makes it impossible to create any mocking frameworks for unit testing, which is a very common tool in the testing world. Without this we're left with using dummies and fakes - for now creating them manually, in the future I'm sure there will be plugins that support generating these from e.g. protocols.<br class=""></div><div class=""><br class=""></div><div class="">The iOS community seems to be somewhat behind when it comes to automation compared to other languages and platforms - and in its current version Swift seems to make the barrier to entry even higher compared to Objective C, where mocking and stubbing is a possibility due to the dynamic nature of the language.</div><div class=""><br class=""></div><div class="">Could anyone shed some light on why the decision was made to leave this feature out? Is it just a feature that due to complexity will be pushed for later? Or is it a security consideration?<br class=""></div></div></div></blockquote><br class=""></div><div>Yes, yes, and yes. Better reflection is something we'd like to support eventually, and a lot of the necessary metadata is already present at runtime, but not exposed. Designing interfaces takes time, and there are also security and secrecy concerns regarding what ought to be reflected, so there needs to be language design as well to control what is available to runtime reflection. All that said, runtime reflection is not the only way to approach mocking and stubbing. Swift's as static as you write it; if you define your component interfaces using protocols and generics, those protocols can be conformed to with mock or stub implementations without any need for runtime hacking.</div><div><br class=""></div><div>-Joe</div><br class=""></body></html>