Matthew Jones
Matthew Jones

Reputation: 197

Weird Error With Apple Script Bridge - iTunes

I'm trying to create an ObjC application that will control iTunes. I need a method that will return an array of all the playlists in iTunes.

I'm getting the most bizarre, unhelpful error message ever... First the code:

#import "MusicControl.h"
#import "iTunes.h"

@implementation MusicControl


- (SBElementArray *) playlists {  


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

     NSArray *sources = [iTunes sources];
     iTunesSource *librarySource = nil;

     for (iTunesSource *source in sources) {
     if ([source kind] == iTunesESrcLibrary) {
     librarySource = source;
     break;
     }
     }

     return [librarySource userPlaylists]; 
} 

@end

I have no idea whether the array return is working or not because, after doing some debugging, I found that where this is bombing out is the very first line where I create the iTunes object, which was copied and pasted from Apple's website...

The error I'm getting is:

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_SBApplication", referenced from:
      objc-class-ref in MusicControl.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any suggestion as the what the heck is going on?

Upvotes: 2

Views: 915

Answers (1)

Monolo
Monolo

Reputation: 18253

This message (and similar ones) means that the linker is looking for some specific symbol, but can't find it. In your case it is SBApplication.

If you have not already done so, you should make sure that you have linked to the ScriptingBridge framework.

To add a framework, click on the project's icon at the top of the left hand bar in Xcode, then select Build Phases. If Link With Binary Libraries is not already expanded, do that and add the framework.

The same procedure can be used for plain libraries (a framework is really just a wrapper around a library, at least for the purpose of this discussion).

Upvotes: 4

Related Questions