Skip to content

Instantly share code, notes, and snippets.

@rustle
Created September 15, 2012 02:04
Show Gist options
  • Save rustle/3726046 to your computer and use it in GitHub Desktop.
Save rustle/3726046 to your computer and use it in GitHub Desktop.
Weak linking with extern NSString *const issue
#import <Social/Social.h>
/* Compiled with iOS 6 SDK
* Social.framework weak linked (Optional)
* Run on iOS 5.1 (simulator and device)
*/
// http://simx.me/technonova/software_development/checking_for_weak_linked_frameworks.html
//http://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html#//apple_ref/doc/uid/20002378-106633-CJBGFCAC
extern NSString *const SLServiceTypeFacebook __attribute__((weak_import));
int main(int argc, char *argv[])
{
@autoreleasepool
{
NSLog(@"%p", &SLServiceTypeFacebook);
BOOL symbolExists = (&SLServiceTypeFacebook != NULL);
if (symbolExists)
{
NSString *serviceType = SLServiceTypeFacebook;
NSLog(@"serviceType %@", serviceType);
}
NSLog(@"Didn't crash");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment