In my Cocoa application written in Swift (Xcode 6 Beta 6 on OS X Mavericks) I would like to use a bundle resource. Is does not use any external libraries but only the WebKit.framework
. I encountered an odd linker problem with the code I wrote and could reduce it to the second line in this snippet:
var bundle = NSBundle.mainBundle()
// Leads to linker error!
var path = bundle.pathForResource(resource, ofType: "js")
If I comment out the pathForResource
line it compiles and runs fine. Otherwise it causes the build to fail. That is the output in where Xcode shows the error:
Ld /Users/Peter/Library/Developer/Xcode/DerivedData/OFrame-cyxuoheofsrztibvnaxacjxvlzsl/Build/Products/Debug/OFrame.app/Contents/MacOS/OFrame normal x86_64
cd /Users/Peter/Projekte/OFrame
export MACOSX_DEPLOYMENT_TARGET=10.9
/Applications/Xcode6-Beta6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode6-Beta6.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -L/Users/Peter/Library/Developer/Xcode/DerivedData/OFrame-cyxuoheofsrztibvnaxacjxvlzsl/Build/Products/Debug -F/Users/Peter/Library/Developer/Xcode/DerivedData/OFrame-cyxuoheofsrztibvnaxacjxvlzsl/Build/Products/Debug -filelist /Users/Peter/Library/Developer/Xcode/DerivedData/OFrame-cyxuoheofsrztibvnaxacjxvlzsl/Build/Intermediates/OFrame.build/Debug/OFrame.build/Objects-normal/x86_64/OFrame.LinkFileList -Xlinker -rpath -Xlinker @executable_path/../Frameworks -mmacosx-version-min=10.9 -lswiftCore -L/Applications/Xcode6-Beta6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -Xlinker -force_load -Xlinker /Applications/Xcode6-Beta6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a -Xlinker -add_ast_path -Xlinker /Users/Peter/Library/Developer/Xcode/DerivedData/OFrame-cyxuoheofsrztibvnaxacjxvlzsl/Build/Intermediates/OFrame.build/Debug/OFrame.build/Objects-normal/x86_64/OFrame.swiftmodule -framework WebKit -Xlinker -dependency_info -Xlinker /Users/Peter/Library/Developer/Xcode/DerivedData/OFrame-cyxuoheofsrztibvnaxacjxvlzsl/Build/Intermediates/OFrame.build/Debug/OFrame.build/Objects-normal/x86_64/OFrame_dependency_info.dat -o /Users/Peter/Library/Developer/Xcode/DerivedData/OFrame-cyxuoheofsrztibvnaxacjxvlzsl/Build/Products/Debug/OFrame.app/Contents/MacOS/OFrame
Undefined symbols for architecture x86_64:
"__TFSs26_forceBridgeFromObjectiveCU__FTPSs9AnyObject_MQ__Q_", referenced from:
__TFC6OFrame15FrameController16injectJavaScriptfS0_FCSo8NSStringT_ in FrameController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I read about architecture problems with frameworks but they all were related to the framework as a whole. Not the use of single method. This leaves me puzzled. Even more irritating is that NSBundle.pathForResource
is a class method in the foundation framework. Is there kind of a cache for built objects which I eventually need to purge?
I feel cursed. Whenever I try to do something with Xcode I encounter the strangest problems.