Swift beta 6 - 令人困惑的链接器错误消息 [英] Swift beta 6 - Confusing linker error message
问题描述
在使用 Xcode 6 beta 6 构建面向 iOS 8 的 Swift 程序时,我收到来自链接器的错误消息.此代码在 beta 5 中编译并正确运行.
I'm getting an error message from the linker when building a Swift program with Xcode 6 beta 6, targeting iOS 8. This code compiled and ran correctly with 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)
}
我很想知道在此代码中查找错误的位置的提示,以便我可以修复它.谢谢.
I'd appreciate a hint about where in this code to look for the error so I can fix it. Thank you.
推荐答案
即使使用新版本的 Beta6,我也遇到了这个错误,该版本是在坏版本被拉出数小时后发布的.
I got this error even with the new version of Beta6 that was release hours after the bad one got pulled.
我通过删除派生文件夹的内容解决了这个错误和其他类似的难以辨认的错误.您可以通过转到首选项">位置"来找到该文件夹所在的位置.
I've solved this and other similarly illegible errors by deleting the contents of the Derived folder. You can find where that folder is located by going to Preferences > Locations.
默认路径为:/Users/[您的用户名]/Library/Developer/Xcode/DerivedData
The default path is: /Users/[your username]/Library/Developer/Xcode/DerivedData
您也可以在 Xcode 中打开 Product 菜单时按住 Option
,这会将 Clean
更改为 Clean Build Folder
... 和无需文件夹搜索即可完成相同的任务.
You can also hold Option
while the Product menu is open in Xcode, which will change Clean
to Clean Build Folder
... and accomplish the same task without having to folder-hunt.
这篇关于Swift beta 6 - 令人困惑的链接器错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!