问题
I've just updated the Facebook iOS SDK in my project from 3.0 to 3.1. The project does not compile anymore. Instead I get the following linker errors:
Undefined symbols for architecture i386:
"_ACFacebookAppIdKey", referenced from:
-[FBSession authorizeUsingSystemAccountStore:accountType:permissions:defaultAudience:isReauthorize:] in FacebookSDK(FBSession.o)
"_ACFacebookAudienceEveryone", referenced from:
-[FBSession authorizeUsingSystemAccountStore:accountType:permissions:defaultAudience:isReauthorize:] in FacebookSDK(FBSession.o)
"_ACFacebookAudienceFriends", referenced from:
-[FBSession authorizeUsingSystemAccountStore:accountType:permissions:defaultAudience:isReauthorize:] in FacebookSDK(FBSession.o)
"_ACFacebookAudienceKey", referenced from:
-[FBSession authorizeUsingSystemAccountStore:accountType:permissions:defaultAudience:isReauthorize:] in FacebookSDK(FBSession.o)
"_ACFacebookAudienceOnlyMe", referenced from:
-[FBSession authorizeUsingSystemAccountStore:accountType:permissions:defaultAudience:isReauthorize:] in FacebookSDK(FBSession.o)
"_ACFacebookPermissionsKey", referenced from:
-[FBSession authorizeUsingSystemAccountStore:accountType:permissions:defaultAudience:isReauthorize:] in FacebookSDK(FBSession.o)
"_OBJC_CLASS_$_ASIdentifierManager", referenced from:
objc-class-ref in FacebookSDK(FBSettings.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The Facebook docs clearly say:
The SDK relies on three other frameworks (AdSupport, Accounts and Social) to use the Facebook features built into iOS6.
Those frameworks do not exist in Xcode 4.2 . Is there any workaround, i.e. can I download (where?) and add the frameworks manually to my project and will that suffice to get rid of the compile errors or do I have to upgrade to Xcode 4.5?
回答1:
Those frameworks are part of iOS 6 (well, except for Accounts
, which is from iOS 5). You won't be able to use them without upgrading to Xcode 4.5, and consequently, iOS 6 SDK.
You can still set your deployment target down to iOS 4.3, if that's your concern.
I think your options are:
- Upgrade to Xcode 4.5, or
- Use Facebook SDK 3.0.
回答2:
To make things clear:
For XCode 4.5:
If you use FB SDK3.0, you only need to add Accounts and FacebookSDK frameworks.
If you use FB SDK3.1, you need to add Accounts, FacebookSDK, Social, and AdSupport frameworks.
If you use FB SDK3.2++, check by yourself what other frameworks you may or may not need. ;)
Hope that sums it up nicely for everyone.
回答3:
The SDK relies on three other frameworks (AdSupport, Accounts and Social).
To add these, go to the 'Linked Frameworks and Libraries' section of the target's Summary pane, and add them.
回答4:
Sobri is right. Either upgrade to Xcode 4.5 or use SDK 3.0 or If you want to use 3.1 then download the source from github, modify the build file(basically remove the references to frameworks provided by iOS 6.0 ) and rebuild the SDK. That ways you can use the SDK 3.1 as well as run it on older XCode versions.
回答5:
The following steps may be helpful to resolve this issue
- Download Facebook iOS SDK 3.0 from links present in the URL http://developers.facebook.com/ios/features/whats-new-ios-sdk-3/
- Add the FacebookSDK framework from Mac Documents directory
- Add sqlite3 to project
Then, I've tried the code in http://developers.facebook.com/docs/howtos/login-with-facebook-using-ios-sdk/ with the following changes (as it is for Facebook iOS SDK 3.1)
- Replace
openActiveSessionWithReadPermissions
withopenActiveSessionWithPermissions
- Replace
[FBSession.activeSession handleDidBecomeActive];
with[FBSession activeSession];
This worked for me. Try it once.
Thanks, prodeveloper.
来源:https://stackoverflow.com/questions/12598209/facebook-ios-sdk-3-1-with-xcode-4-2-linker-errors