Open KarthikS941 opened 6 years ago
SwiftDocs(file: File(path: "/Users/.../sample.swift")!, arguments: [])!
arguments here should at least contains full path to the file ["/Users/.../sample.swift"]
.
@ainopara I still get 'Could not read contents of /Users/karthiksa/sample.swift
.
/*
Abstract:
Application preview view.
*/
import UIKit
import AVFoundation
class PreviewView: UIView {
var videoPreviewLayer: AVCaptureVideoPreviewLayer {
guard let layer = layer as? AVCaptureVideoPreviewLayer else {
fatalError("Expected `AVCaptureVideoPreviewLayer` type for layer. Check PreviewView.layerClass implementation.")
}
return layer
}
var session: AVCaptureSession? {
get {
return videoPreviewLayer.session
}
set {
videoPreviewLayer.session = newValue
}
}
// MARK: UIView
override class var layerClass: AnyClass {
return AVCaptureVideoPreviewLayer.self
}
}
Thats the code in 'sample.swift'
Attaching Error Log in this.
`/Users/karthiksa/SwiftyPaper/SwiftyPaper/SwiftyPaper/ViewController.swift`
produced error: error: Couldn't lookup symbols:
__T021SourceKittenFramework9SwiftDocsVN
@KarthikS941 It seems you need to embed SourceKittenFramework.framework
in your application.
@KarthikSCP Is there a file at this path /Users/karthiksa/sample.swift
?
If there is, could you please share output of this code?
do {
try String(contentsOfFile: "/Users/karthiksa/sample.swift", encoding: .utf8)
} catch {
print("Error: \(error)")
}
Here is the output,
Error: Error Domain=NSCocoaErrorDomain Code=257 "The file “ViewController.swift” couldn’t be opened because you don’t have permission to view it." UserInfo={NSFilePath=/Users/karthiksa/SwiftyPaper/SwiftyPaper/SwiftyPaper/ViewController.swift, NSUnderlyingError=0x6040002419b0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
According to the error message, your application failed to get access to the content of this file. This seems not a SourceKitten issue. I am not expert in macOS application developing, so I can not give any further guidance.
I am trying to extract document JSON structure from a swift file using SwiftDocs class. I have imported Sourcekitten framework and below is the code snippet of the same.
Expecting it to print a JSON string similar to below one
Instead, I am getting cannot read file error.
When I did a 'po' this is what I got