Claudiu
Claudiu

Reputation: 229461

trouble linking to yaml framework

I'm making an iPhone game and would like to use YAML for the data files. Thanks to this question I went ahead and got the syck library. I managed to compile the library with xCode and to import the framework into my project[1]. My code successfully imports the header files, and xCode even finds the completions, but when I try to run the following code, I get an invalid selector exception:

NSMutableArray *arr = [[NSMutableArray arrayWithCapacity:4] retain];

[arr addObject:@"FOO BAR BAZ QUUX"];
[arr addObject:@"FOO BAR BAZ QUUX"];
[arr addObject:@"FOO BAR BAZ QUUX"];
[arr addObject:@"FOO BAR BAZ QUUX"];

NSLog([arr yamlDescriptionWithIndent:0]);
[arr release];

This is the error I get:

2013-04-01 23:27:50.530 PhaseWrath[13910:207] -[__NSArrayM yamlDescriptionWithIndent:]: unrecognized selector sent to instance 0x5548a30
2013-04-01 23:27:50.533 PhaseWrath[13910:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM yamlDescriptionWithIndent:]: unrecognized selector sent to instance 0x5548a30'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0145f5a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x015b3313 objc_exception_throw + 44
    2   CoreFoundation                      0x014610bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x013d0966 ___forwarding___ + 966
    4   CoreFoundation                      0x013d0522 _CF_forwarding_prep_0 + 50
    5   PhaseWrath                          0x00005e85 +[Skeleton initialize] + 517
    6   libobjc.A.dylib                     0x015b3d9b _class_initialize + 380
    7   libobjc.A.dylib                     0x015bb73f prepareForMethodLookup + 73
...

It seems like the header files get parsed, but something goes wrong at the point where the library code would actually be linked... any ideas? I'm quite new to xCode and developing for the iPhone in general.

[1] If I did something wrong it probably was at this step.

Upvotes: 3

Views: 222

Answers (1)

Stuart M
Stuart M

Reputation: 11588

Are you passing the -ObjC and -all_load linker flags in your build settings? Those are required when linking to libraries that include Objective-C categories (which is what Syck uses to add methods to NSArray and other builtin classes). See these for details:

Upvotes: 1

Related Questions