title: Crash when passing Swift objects to JavaScript
body: <p>I'm trying to use a Swift class with <a href="http://www.bignerdranch.com/blog/javascriptcore-example/" rel="nofollow">JavaScriptCore</a>. This is what I have:</p>
  
  <pre><code>import JavaScriptCore
  
  @objc(MyObjExport) // explicit name required for class_copyProtocolList to work
  public protocol MyObjExport: JSExport {
      var foo: String! { get }
  }
  
  @objc(MyObj)
  public class MyObj: NSObject, MyObjExport
  {
      public var foo: String! { return "bar" }
  }
  </code></pre>
  
  <p>Which produces the following "<code>MyModule-Swift.h</code>" header:</p>
  
  <pre><code>SWIFT_PROTOCOL("MyObjExport")
  @protocol MyObjExport &lt;JSExport&gt;
  @property (nonatomic, readonly, copy) NSString * foo;
  @end
  
  SWIFT_CLASS("MyObj")
  @interface MyObj : NSObject &lt;MyObjExport&gt;
  @property (nonatomic, readonly, copy) NSString * foo;
  @end
  </code></pre>
  
  <p>I can create and use this object just fine from other Obj-C code, but:</p>
  
  <pre><code>MyObj *foo = [[MyObj alloc] init];
  
  [JSValue valueWithObject:foo inContext:nil]; // EXC_BAD_ACCESS
  </code></pre>
  
  <p>It crashes in the JSCore implementation:</p>
  
  <pre><code>#0  0x00007fff87c5ca73 in objectToValueWithoutCopy(JSContext*, objc_object*) ()
  #1  0x00007fff87c5c27e in objectToValue(JSContext*, objc_object*) ()
  #2  0x00007fff87c5c20c in +[JSValue valueWithObject:inContext:] ()
  </code></pre>
  
  <p>(Nothing is logged to the console.) If I implement the class in Obj-C instead of Swift, it works fine. What's wrong and how can I fix this?</p>