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
Here's the code in question:
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.
Another cause of this error (seen with Xcode 6.1.1, and Xcode 6.2 Beta 3), is having an enum with only one case in one class, and declaring a variable of that type in a second class.
This code will cause a linker error:
class ClassA {
enum ExampleEnum {
case Option1
}
}
class ClassB {
var example: ClassA.ExampleEnum = .Option1
}
This will fix it.
class ClassA {
enum ExampleEnum {
case Option1
case Option2 // Added a second case
}
}
class ClassB {
var example: ClassA.ExampleEnum = .Option1
}
Radar for more info and a sample project: http://openradar.appspot.com/19369147
An enum with only one case is pretty useless in practice and so the compiler is probably optimizing it away or something. I hit this when setting up a new project, using an enum for achievements to be determined later, and had just 1 placeholder.
Also note: Use Watchdog http://watchdogforxcode.com/ to avoid having to worry about Derived Data issues.
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.
The default path is: /Users/[your username]/Library/Developer/Xcode/DerivedData
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.
For other people that might stumble on this error. I have had this when implementing CocoaPods
and not setting my target's Other Linker Flags
to $(inherited)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With