XCode 8的编译速度很慢,SourceKitService使用300%以上的CPU

时间:2017-02-18 01:33:35

标签: ios xcode compilation

我的Xcode编译真的很慢。 Activity监视器指示SourceKitService的CPU使用率为~330%,swift为100%。那里有什么不正常的事吗?

我已经读过几个地方,SourceKitService可能正在努力猜测数组和字典类型,所以我会尝试让它们更具有说明性。由于这些帖子来自Xcode 5-6,我想知道这仍然是一个问题

1 个答案:

答案 0 :(得分:3)

感谢@Mike提供构建时间分析器的链接,非常棒。事实证明,XCode需要330秒才能编译:

func asJson() -> JSON {
    let dict: [String: Any?] = [
        "video": video.asJson,
        "asset": asset.url.path,
        "canBeShared": canBeShared,
        "videoSource": videoSource.path,
        "previewSource": previewSource.documentPath,
        "expectedResizedVideo": expectedResizedVideo.documentPath,
        "videoDestination": videoDestination,
        "previewDestination": previewDestination,
        "fileId": fileId,
        "isRecordCreated": isRecordCreated,
        "isPreviewUploaded": isPreviewUploaded,
        "isPreviewRegistered": isPreviewRegistered,
        "isSharingPreviewReady": isSharingPreviewReady,
        "isVideoUploaded": isVideoUploaded,
        "isVideoRegistered": isVideoRegistered,
        "isPosted": isPosted,
        "isPostRegistered": isPostRegistered,
        "didResizeVideo": didResizeVideo,
    ]
    return JSON(dict)
}

我改写为

func asJson() -> JSON {
    var dict = [String: Any?]()
    dict["video"] = video.asJson
    dict["asset"] = asset.url.path
    dict["canBeShared"] = canBeShared
    dict["videoSource"] = videoSource.path
    dict["previewSource"] = previewSource.documentPath
    dict["expectedResizedVideo"] = expectedResizedVideo.documentPath
    dict["videoDestination"] = videoDestination
    dict["previewDestination"] = previewDestination
    dict["fileId"] = fileId
    dict["isRecordCreated"] = isRecordCreated
    dict["isPreviewUploaded"] = isPreviewUploaded
    dict["isPreviewRegistered"] = isPreviewRegistered
    dict["isSharingPreviewReady"] = isSharingPreviewReady
    dict["isVideoUploaded"] = isVideoUploaded
    dict["isVideoRegistered"] = isVideoRegistered
    dict["isPosted"] = isPosted
    dict["isPostRegistered"] = isPostRegistered
    dict["didResizeVideo"] = didResizeVideo
    return JSON(dict)
}

这很好用。我将打开Apple的错误