小编典典

Swift Beta 6-令人困惑的链接器错误消息

swift

在使用针对iOS 8的Xcode 6 beta 6构建Swift程序时,链接器出现错误消息。此代码已在Beta 5中正确编译并运行。

Undefined symbol for architecture x86_64:
__TFSs26_forceBridgeFromObjectiveCU__FTPSs9AnyObject_MQ__Q_", referenced from:
 __TFC8RayTrace14RayTracingPlot15drawFocalPointfS0_FT_T_ in RayTracingPlot.o
ld: symbol(s) not found for architecture x86_64

这是有问题的代码:

private func drawFocalPoint() {
    var attributes = Dictionary<String, AnyObject>()

    let FString: String = "F"
    let distance: CGFloat = focalDistance

    let centerX = CGRectGetMidX(bounds)
    let centerY = CGRectGetMidY(bounds)

    let circleRadius: CGFloat = 4.0
    let focalPointFrame = CGRectMake(0, 0, circleRadius * 2.0, circleRadius * 2.0)
    var path = UIBezierPath(ovalInRect: focalPointFrame)
    let color = UIColor.blackColor()

    let currentContext = UIGraphicsGetCurrentContext()
    CGContextSaveGState(currentContext)
    let shadowColor = UIColor(white:0, alpha:0.75).CGColor
    CGContextSetShadowWithColor(currentContext, CGSizeMake(0, 4), CGFloat(8), shadowColor)

    // Image F
    var imageFPath = UIBezierPath(CGPath: path.CGPath)
    let imageFTransform = CGAffineTransformMakeTranslation((centerX - distance - circleRadius),
        (centerY - circleRadius))
    imageFPath.applyTransform(imageFTransform)
    color.set()
    imageFPath.fill()
    FString.drawAtPoint(CGPointMake(centerX - distance - circleRadius, centerY + 5), withAttributes:attributes)

    CGContextSetShadowWithColor(currentContext, CGSizeMake(0.0, 0.0), CGFloat(0.0), nil) // Clear shadow
    CGContextRestoreGState(currentContext)
}

我希望在此代码中找到错误的提示,以便我可以解决。谢谢。


阅读 223

收藏
2020-07-07

共1个答案

小编典典

即使是新版本的Beta6,我也遇到了这个错误,它是在坏版本被撤出后的数小时内发布的。

通过删除“派生”文件夹的内容,我已经解决了此错误以及其他类似的难以辨认的错误。您可以转到“偏好设置”>“位置”找到该文件夹​​的位置。

默认路径为:/ Users / [您的用户名] / Library / Developer / Xcode / DerivedData

您也可以按住Option,同时产品菜单是在Xcode,这将改变开CleanClean Build Folder......而完成同样的任务,而不必到文件夹迫害。

2020-07-07