1

To use ScriptingBridge with iTunes, I used:

iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];

However, when I run the application, (I have traced the source of the error to the above line), I get a build failed, and these errors:

Apple Mach-O Linker (Id) Error
"_OBJC_CLASS_$_SBApplication", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64

and

Apple Mach-O Linker (Id) Error
Linker command failed with exit code 1 (use -v to see invocation)

How do I solve this issue? I copied and pasted that line from the Apple Developer Scripting Bridge Programming Guide, so I can't imagine it would cause a problem.

2 Answers2

4

A linker error like that suggests that you simply haven't added ScriptingBridge.framework as a framework linked to your product.

Chris N
  • 905
  • 5
  • 10
-1

Since the SpringBoard isn't a framework and you can't link to it when compiling you must access the class at runtime. The method I would recommend is this:

#import <objc/runtime.h>
SBApplication* iTunes = [objc_getClass("SBApplication") applicationWithBundleIdentifier:@"com.apple.iTunes"];
Otium
  • 1,098
  • 8
  • 20
  • I'm doing this, but when I try to call the methods from the iTunes.h file (which I didn't forget to #import), I get an error `no visible @interface for SBApplication declares the selector` (I'm trying to run `[iTunes run];`) What am I doing wrong? – user1231779 Apr 17 '12 at 00:38
  • If I switch the class from SBApplication to iTunesApplicaion, the error goes away but none of the methods do anything – user1231779 Apr 17 '12 at 02:34