C
C
Cassar2014-07-29 12:35:10
Objective-C
Cassar, 2014-07-29 12:35:10

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 iTunes
and 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)
    }
}

application refused to build with type error
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

Searching the Internet did not give any intelligible solutions to this problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
deleted-mezhevikin, 2014-07-29
@Cassar

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.

T
TAURUSiv43, 2014-10-05
@TAURUSiv43

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 question

Ask a Question

731 491 924 answers to any question