<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">IIRC this isn’t possible because there’s no Runtime to query for classnames (it’s inherently unsafe anyway).<div class=""><br class=""></div><div class="">You might want to look into a better way of doing that you’re trying to do.</div><div class=""><br class=""></div><div class="">— Harlan</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 10, 2015, at 12:42 AM, Matthew Davies 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=""><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I am using the Swift build tool & package manager. I'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 class=""></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 class=""></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I can (in the iOS & OS X runtimes) use "NSClassFromString", but this is unavailable in the Swift build tool. How can I (or can I?) get the same functionality?</div><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><br class=""></div><div dir="ltr" class=""><br class=""><table border="0" cellspacing="0" cellpadding="0" width="470" style="color:rgb(136,136,136);font-size:12.8000001907349px;width:470px" class=""><tbody class=""><tr valign="top" class=""><td style="font-family:Arial;font-stretch:normal;font-size:14px;color:rgb(100,100,100);padding-left:10px" class=""><div class=""><b class="">Matthew Davies</b><br class="">Junior Developer, <a href="http://geostrategies.com/" target="_blank" class="">GeoStrategies</a></div><div class="">Director of Photography, <a href="http://offblockfilms.com/" target="_blank" class="">OffBlock Films</a></div><div style="color:rgb(141,141,141);font-size:13px;padding:5px 0px" class=""><a href="tel:209-225.3246" style="color:rgb(141,141,141);text-decoration:none" target="_blank" class="">209-225-3246</a> <span style="color:rgb(102,102,102);display:inline-block" class="">|</span> <span style="display:inline-block" class=""><a href="tel:209-202-3284" style="color:rgb(141,141,141);text-decoration:none" target="_blank" class="">209-202-3284</a></span> <span style="color:rgb(102,102,102);display:inline-block" class="">|</span> <span style="display:inline-block" class=""><a href="mailto:matthew@daviesgeek.com" style="color:rgb(141,141,141);text-decoration:none" target="_blank" class="">matthew@daviesgeek.com</a></span> <span style="color:rgb(102,102,102);display:inline-block" class="">|</span> <span style="white-space:nowrap;display:inline-block" class=""><a href="https://daviesgeek.com/" style="color:rgb(141,141,141);text-decoration:none" target="_blank" class="">daviesgeek.com</a></span></div><div style="margin-top:5px" class=""><a href="http://facebook.com/daviesgeek" style="color:rgb(17,85,204)" target="_blank" class=""><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/facebook.png" width="16" height="16" class=""></a> <a href="http://us.linkedin.com/in/daviesgeek" style="color:rgb(17,85,204)" target="_blank" class=""><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/linkedin.png" width="16" height="16" class=""></a> <a href="http://twitter.com/daviesgeek" style="color:rgb(17,85,204)" target="_blank" class=""><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/twitter.png" width="16" height="16" class=""></a> <a href="http://daviesgeek.com/feed.xml" style="color:rgb(17,85,204)" target="_blank" class=""><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/blogRSS.png" width="16" height="16" class=""></a> <a href="http://github.com/daviesgeek" style="color:rgb(17,85,204)" target="_blank" class=""><img src="https://s3.amazonaws.com/images.wisestamp.com/icons/github.png" width="16" height="16" class=""></a></div><div class=""><br class=""></div></td></tr></tbody></table></div></div></div></div></div></div></div></div></div></div></div>
</div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=z0Ft8gvIaLt1zLwfkl4og6osLD9N8tlWJY1PY2zqWLU-2Fv-2BDLH6VxWwQCXynivCOb5-2BBN-2BJEp5gubv1MozoYGY8zo1E6KS0eE69JALo6FKczb0Ty1j6coLzR7sEdaIv-2BpnbF3-2BeQzph9oj6fus40BvrXHWaZ98pdCKVS00W-2BGWY4k955awqUzLmqUslfKq86Xivkd4ATjr-2FSpjOXSRoz5XwT8J7XIeo3Xo3RseH3BkpM-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></div></body></html>