问题
I'm trying to get this set up for my company: https://developers.facebook.com/docs/tutorials/mobile-app-ads/
I used the instructions here to get it into our app: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/3.1/
From my initial attempt to integrate and get data, it seems like this can only work for iOS 6.
When I run the app for iOS 6 simulator it runs fine, but for an actual device running iOS 5, it fails during linking:
ld: framework not found Social
Is it true that this FB SDK functionality can only work in iOS 6+ apps? If so, does anyone know how to integrate with FB mobile ads reporting for apps that support iOS 4.3 to iOS 6+.
Thanks!
回答1:
The new SDK actually requires 6.
Not sure what was causing the error, but to eliminate the build problem, I just cleaned the build folder, deleted the derived data from the project, and removed & re-added the facebook libs.
Then to prevent this from blowing up on pre-iOS 6 situations I added this to my app:
+ (BOOL)isSocialFrameworkAvailable
{
static BOOL available = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
available = NSClassFromString(@"SLComposeViewController") != nil;
});
return available;
}
- (BOOL)application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions
{
// [...]
if ([[self class] isSocialFrameworkAvailable]) {
[FBSettings setLoggingBehavior:[NSSet setWithObjects:
FBLoggingBehaviorFBRequests,
FBLoggingBehaviorFBURLConnections,
FBLoggingBehaviorAccessTokens,
FBLoggingBehaviorPerformanceCharacteristics,
FBLoggingBehaviorSessionStateTransitions,
nil]];
NSDate *facebookIdPublishedDate = [[NSUserDefaults standardUserDefaults] objectForKey:@"facebookIdPublishedDate"];
if (!facebookIdPublishedDate) {
[[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"facebookIdPublishedDate"];
[FBSettings publishInstall:@"XXXXXXXXXXXXXXXX"];
}
}
// [...]
}
回答2:
Just to clarify, the Facebook iOS SDK supports OS versions 4.3 and up. However, if you want to work with iOS6 then you need to link 3 frameworks: 'Accounts', 'AdSupport' and 'Social'. Very important to note that when you link these frameworks you make them optional to avoid compile errors when running on devices prior to iOS6.
Mobile ads installs should therefore work with version 4.3+ since the Facebook SDK supports 4.3+.
回答3:
The new SDK requires iOS 5 or 6 i think - i don't think there's a way to use the 3.1 SDK with iOS versions before 5 - see Facebook with iOS5 and iOS6 for details on supporting both 5 and 6, but i don't think this applies to 4
来源:https://stackoverflow.com/questions/13299474/how-to-integrate-facebooks-mobile-ad-functionality-in-our-app-that-supports-ios