SLServicesType don't have correct availability attribute

Originator:doug
Number:rdar://12305923 Date Originated:
Status:Open Resolved:
Product:iPhone SDK Product Version:6.0
Classification:Serious Bug Reproducible:Always
 
<Social/SLServiceTypes.h> declares three constants

SOCIAL_EXTERN NSString *const SLServiceTypeTwitter;
SOCIAL_EXTERN NSString *const SLServiceTypeFacebook;
SOCIAL_EXTERN NSString *const SLServiceTypeSinaWeibo;

with no availability attribute, meaning that if they are linked weakly, they don't behave correctly.

The following code fails

#import <Social/Social.h>

/* Compiled with iOS 6 SDK
 * Social.framework weak linked (Optional)
 * Run on iOS 5.1 (simulator and device)
 * Output is:
 * 0x0
 * About to crash
 * +++ EXC_BAD_ACCESS +++
 */

int main(int argc, char *argv[])
{
	@autoreleasepool
	{
		NSLog(@"%p", &SLServiceTypeFacebook);
		if (&SLServiceTypeFacebook)
		{
			NSLog(@"About to crash");
			NSString *serviceType = SLServiceTypeFacebook; // crashes here with EXC_BAD_ACCESS (code=2, address=0x0)
			NSLog(@"Not reached %@", serviceType);
		}
	}
	return 0;
}

because of this incorrect availability.

The constants should have a __attribute__((weak_import)) qualifier so that they behave correctly.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!