Answer the question
In order to leave comments, you need to log in
Why is Swift not friendly with ScriptingBridge.framework?
There is a need for a Swift application to communicate with iTunes. Naturally, ScriptingBridge.framework was chosen for these purposes. The iTunes.hc header was generated using
sdef /Applications/iTunes.app | sdp -fh --basename iTunesand added to the project along with AppName-Bridging-Header.h with the line #import "iTunes.h". The ScriptingBridge.framework itself was also linked into the project. However, when it comes to direct interaction, such as getting an iTunes instance and reading its properties -- the current track, for example:
class iTunesWorker: NSObject {
var iTunesInstance: iTunesApplication? = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") as? iTunesApplication
func fetchCurrentTrackInfo() {
let currentTrack: iTunesTrack? = iTunesApp?.currentTrack
let trackName: String? = currentTrack?.name
println(trackName)
}
}
Symbols for architecture undefined the x86_64:
"_OBJC_CLASS _ $ _ iTunesApplication", referenced This 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 This from:
__TFC5NowP_14iTunesWorker21fetchCurrentTrackInfofS0_FT_T_ in iTunesWorker.o
ld: symbol (s) not found for architecture x86_64
Answer the question
In order to leave comments, you need to log in
He is not friendly with many things, for example, there are problems with coredata.framework. I think you should not rush and wait for September with the official release.
If it is still relevant, then you can do it as follows - describe the interaction with iTunes in the Obj-C class and then use it from Swift. Checked it works.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question