<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I am using the Swift build tool &amp; package manager. I&#39;m trying to figure out how to instantiate a class from a string. For instance, in PHP I can do:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">$instance = new $className</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I can (in the iOS &amp; OS X runtimes) use &quot;NSClassFromString&quot;, but this is unavailable in the Swift build tool. How can I (or can I?) get the same functionality?</div><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><br></div><div dir="ltr"><br><table border="0" cellspacing="0" cellpadding="0" width="470" style="color:rgb(136,136,136);font-size:12.8000001907349px;width:470px"><tbody><tr valign="top"><td style="font-family:Arial;font-stretch:normal;font-size:14px;color:rgb(100,100,100);padding-left:10px"><div><b>Matthew Davies</b><br>Junior Developer, <a href="http://geostrategies.com/" target="_blank">GeoStrategies</a></div><div>Director of Photography, <a href="http://offblockfilms.com/" target="_blank">OffBlock Films</a></div><div style="color:rgb(141,141,141);font-size:13px;padding:5px 0px"><a href="tel:209-225.3246" style="color:rgb(141,141,141);text-decoration:none" target="_blank">209-225-3246</a> <span style="color:rgb(102,102,102);display:inline-block">|</span> <span style="display:inline-block"><a href="tel:209-202-3284" style="color:rgb(141,141,141);text-decoration:none" target="_blank">209-202-3284</a></span> <span style="color:rgb(102,102,102);display:inline-block">|</span> <span style="display:inline-block"><a href="mailto:matthew@daviesgeek.com" style="color:rgb(141,141,141);text-decoration:none" target="_blank">matthew@daviesgeek.com</a></span> <span style="color:rgb(102,102,102);display:inline-block">|</span> <span style="white-space:nowrap;display:inline-block"><a href="https://daviesgeek.com/" style="color:rgb(141,141,141);text-decoration:none" target="_blank">daviesgeek.com</a></span></div><div style="margin-top:5px"><a href="http://facebook.com/daviesgeek" style="color:rgb(17,85,204)" target="_blank"><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/facebook.png" width="16" height="16"></a> <a href="http://us.linkedin.com/in/daviesgeek" style="color:rgb(17,85,204)" target="_blank"><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/linkedin.png" width="16" height="16"></a> <a href="http://twitter.com/daviesgeek" style="color:rgb(17,85,204)" target="_blank"><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/twitter.png" width="16" height="16"></a> <a href="http://daviesgeek.com/feed.xml" style="color:rgb(17,85,204)" target="_blank"><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/blogRSS.png" width="16" height="16"></a>  <a href="http://github.com/daviesgeek" style="color:rgb(17,85,204)" target="_blank"><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/github.png" width="16" height="16"></a></div><div><br></div></td></tr></tbody></table></div></div></div></div></div></div></div></div></div></div></div>
</div>