Objective-c – symbol not found when using ScriptingBridge.framework (Mac OS X)


I have included the ScriptingBridge.framework in the target, and it currently shows under Link Binary with Libraries.

I generated a header using:

sdef "/Applications/Address Book.app" | sdp -fh –basename AddressBook

The header was generated ok. However, at compile time, I get the following error:

Undefined symbols:
".objc_class_name_AddressBookPerson", referenced from:
literal-pointer@__OBJC@__cls_refs@AddressBookPerson in ServerController.o

Best Solution

The linking problem disappeared when I removed the offending line: asking a scriptable object for its class (AddressBookPerson).

[AddressBookPerson class]

I replaced the call to class with classForScriptingClass as shown below:

AddressBookApplication *sab = [SBApplication applicationWithBundleIdentifier:@"com.apple.AddressBook"];

NSArray *array = sab.selection;
if ( [array count] > 0 ) {
   AddressBookItem *item = [array objectAtIndex:0];
   if ( item && [item isKindOfClass:[sab classForScriptingClass:@"person"]]) {
      NSString *vCard = [(AddressBookPerson *) item vcard];

where "person" is the name of the class as specified in the scripting definition file generated by sdef.