我有一个简单的Swift类,可以在创建它的XCode 8.1项目中很好地工作(该类中有更多类,但为简洁起见,示例被删减了)。

import UIKit
import AVFoundation

public class ExampleView: UIView {

   let captureSession = AVCaptureSession()
   var previewLayer : AVCaptureVideoPreviewLayer?

   override init (frame : CGRect) {
      super.init(frame : frame)
   }

   convenience init () {
      self.init(frame:CGRect.zero)
   }

   required public init(coder aDecoder: NSCoder) {
      fatalError("This class does not support NSCoding")
   }

   func doSomething(){
      print("do something here.....")
   }
}


并在viewDidLoad()中使用

let example = ExampleView(frame: self.view.layer.frame);
example.doSomething()


我创建了新的Hyperloop iOS项目(SDK 5.5.1.GA),并将其与关联的appc.js一起添加到src目录中。但是,每次应用程序编译时,我都会达到Hyperloop编译的程度,并且失败,并显示以下内容

[TRACE] :  [Hyperloop] metabase took 2243 ms to generate
2016-10-30T15:39:31.675Z | ERROR  | An uncaught exception was thrown!
Cannot read property '1' of null
2016-10-30T15:39:31.676Z | ERROR  | Cannot read property '1' of null


因此,我然后尝试将此文件添加到hyperloop-examples项目的src目录中,但这也会给我以下错误

[TRACE] :  [Hyperloop] metabase took 2425 ms to generate
Swift Generation failed with unknown or unsupported type (AVCaptureSession)     found while compiling /Users/accountone/hyperloop-examples/src/MyExample.swift


我在做什么错,以及有关如何解决此问题的建议?

最佳答案

您是否已将AVFoundation框架添加到appc.js文件中?

10-05 20:05