在使用Xcode 6 beta 6构建Swift程序时,我收到一个来自链接器的错误消息,目标是iOS 8.这个代码使用beta 5编译和运行。
原文链接:https://www.f2er.com/swift/321398.htmlUndefined 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,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) }