I'm trying to create Swift OS X app now, and found difficulty using ScriptingBridge.
I included proper iTunes.h file, and Xcode is not giving any error when I wrote "iTunesApplication" as type.
However, when I compile(run) the app, it gives me error :( Does anybody know about this issue?
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_iTunesApplication", referenced from:
__TFC12LoveYouChloe11AppDelegate10showWindowfS0_FPSs9AnyObject_T_ in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And here is my code:
var iTunes: iTunesApplication = SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") as iTunesApplication
iTunes.playpause()
Instead of
use
Sometimes the compiler gets confused when you are accessing two or more properties in a row(no idea why) so you may need to use a temporary variable. E.g.:
Instead of:
Try:
Or Alternatively the faster (this also works if you declare
iTunesas anSBApplication) :EDIT: You can also generate the .swift headers as specified here: https://github.com/tingraldi/SwiftScripting