Akki Akki - 6 months ago 86
Swift Question

Swift and ScriptingBridge.framework

In my Swift project I need to communicate with iTunes via

ScriptingBridge
framework. According to Apple documentation I create
iTunes.h
file with
sdef /Applications/iTunes.app | sdp -fh --basename iTunes
, then link ScriptingBridge.framework to project and create AppName-Bridging-Header.h file with
#import "iTunes.h"
.

But when I try to get any of iTunes app property, e.g.

var iTunesApp: iTunesApplication? = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") as? iTunesApplication
let currentTrack: iTunesTrack? = iTunesApp?.currentTrack


I get linker error like

Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_iTunesApplication", referenced from:
__TFC5NowP_14iTunesWorker21fetchCurrentTrackInfofS0_FT_T_ in iTunesWorker.o
__TFC5NowP_14iTunesWorkercfMS0_FT_S0_ in iTunesWorker.o
_get_field_types_iTunesWorker in iTunesWorker.o
"_OBJC_CLASS_$_iTunesTrack", referenced from:
__TFC5NowP_14iTunesWorker21fetchCurrentTrackInfofS0_FT_T_ in iTunesWorker.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 use Xcode 6 beta 4. Any ideas?

Answer

I've found that linker errors gone when I get property with valueForKey(key: String?). So this problem seems like imperfection of beta version of Swift.

Comments