Ios SWIFT Xcode 7.3构建特定方法的编译速度非常慢
我正试图加快我的项目的编译速度。我已经阅读了其他在线资源。Ios SWIFT Xcode 7.3构建特定方法的编译速度非常慢,ios,xcode,swift,build,compilation,Ios,Xcode,Swift,Build,Compilation,我正试图加快我的项目的编译速度。我已经阅读了其他在线资源。 我的项目生成设置似乎正确: 优化无(仅调试) 仅为活动体系结构构建是 编译侏儒 当编译器需要在漂亮的链式方法中推断类型时,例如string.characters.split{}.map{}以及需要使用+运算符添加数组时,编译器的速度似乎会减慢。 使用这些建议,我减少了编译时间,但有一种方法在我的机器MBP15的上一个型号上大约需要6秒,我真的不明白为什么 这里有一段痕迹: 6102.4ms/。/视图/CakeView.swift:2
我的项目生成设置似乎正确:
- 优化无(仅调试)
- 仅为活动体系结构构建是
- 编译侏儒
string.characters.split{}.map{}
以及需要使用+
运算符添加数组时,编译器的速度似乎会减慢。使用这些建议,我减少了编译时间,但有一种方法在我的机器MBP15的上一个型号上大约需要6秒,我真的不明白为什么
这里有一段痕迹: 6102.4ms/。/视图/CakeView.swift:221:10 func 更改箭头方向(方向:箭头方向,动画:布尔= 默认设置)
2463.5ms//视图/CakeView.swift:71:9最终版本 didSet{}
2189.8ms/./UIComponents/GradientView.swift:47:9最终版本 didSet{}
有人能找出原因吗?我的项目中的文件是在10分钟内以7.3秒两分钟的时间编译完成的,而不是10分钟。
func changeArrowDirection(direction: ArrowDirection, animated: Bool = false) {
let radius: CGFloat = min(bounds.size.width / 2.0, bounds.size.height / 2.0)
let arrowBackgroundLayerRadius: CGFloat = radius / 2.0
let tailWidth: CGFloat = arrowBackgroundLayerRadius / 4.0
let headWidth: CGFloat = arrowBackgroundLayerRadius / 1.75
let headlength: CGFloat = arrowBackgroundLayerRadius / 2.0
let subArc: CGFloat = cos(asin(1.0 / (2.0 * arrowBackgroundLayerRadius)))
let startPoint: CGPoint
let endPoint: CGPoint
switch direction {
case .Up:
startPoint = CGPoint(x: bounds.size.width / 2.0, y: bounds.size.height / 2.5 + arrowBackgroundLayerRadius - arrowBorderWidth - subArc - arrowCircleBorderWidth)
endPoint = CGPoint(x: bounds.size.width / 2.0, y: bounds.size.height / 1.75 - arrowBackgroundLayerRadius + arrowCircleBorderWidth + arrowBorderWidth)
case .Down:
startPoint = CGPoint(x: bounds.size.width / 2.0, y: bounds.size.height / 1.75 - arrowBackgroundLayerRadius + arrowBorderWidth + subArc + arrowCircleBorderWidth)
endPoint = CGPoint(x: bounds.size.width / 2.0, y: bounds.size.height / 2.5 + arrowBackgroundLayerRadius - arrowCircleBorderWidth - arrowBorderWidth)
case .Left:
startPoint = CGPoint(x: bounds.size.width / 2.0 - arrowBackgroundLayerRadius + arrowBorderWidth + subArc + arrowCircleBorderWidth, y: bounds.size.height / 2.0)
endPoint = CGPoint(x: bounds.size.width / 2.0 + arrowBackgroundLayerRadius - arrowCircleBorderWidth - arrowBorderWidth,y: bounds.size.height / 2.0)
case .Right:
startPoint = CGPoint(x: bounds.size.width / 2.0 + arrowBackgroundLayerRadius - arrowBorderWidth - subArc - arrowCircleBorderWidth, y: bounds.size.height / 2.0)
endPoint = CGPoint(x: bounds.size.width / 2.0 - arrowBackgroundLayerRadius + arrowCircleBorderWidth + arrowBorderWidth,y: bounds.size.height / 2.0)
}
arrowLayer.path = UIBezierPath.bezierPathWithArrowFromPoint(startPoint, endPoint: endPoint, tailWidth: tailWidth, headWidth: headWidth, headLength: headlength).CGPath
}