Twitter login using twitter framework in 'static library'


#1

I have created static library project, in that i am trying to Twitter sharing. But when i tried to on Twitter the application is crashes at following line

NSString *_oAuthNonce = [NSString ab_GUID];

by error:

+[NSString ab_GUID]: unrecognized selector sent to class 0x1a09fd8

ab_GUID this method is present in OAuthCore class

  • (NSString *)ab_GUID
    {
    CFUUIDRef u = CFUUIDCreate(kCFAllocatorDefault);
    CFStringRef s = CFUUIDCreateString(kCFAllocatorDefault, u);
    CFRelease(u);
    return [(NSString *)s autorelease];
    }
    (My all classes are present in static Library)

#2

The +[NSString ab_GUID] method is from a category on NSString. When you’re working with static libs you need to add the “-all_load” flag to the linker (and also potentially the “-ObjC” flag, depending on your setup).

You can read about why that’s necessary here:
http://developer.apple.com/mac/library/qa/qa2006/qa1490.html

A relevant SO discussion is here: