Facebook symbols not found for i386 architecture

2019-07-04 08:40发布

问题:

I get the following error when trying to compile my project in xcode 4 (worked fine in xcode 3.x)

    Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_FBSession", referenced from:
      objc-class-ref in View1Controls.o
  "_OBJC_CLASS_$_FBLoginDialog", referenced from:
      objc-class-ref in View1Controls.o
  "_OBJC_CLASS_$_FBRequest", referenced from:
      objc-class-ref in View1Controls.o
  "_OBJC_CLASS_$_FBStreamDialog", referenced from:
      objc-class-ref in View1Controls.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

Can anyone explain whats wrong? I'm sure I've correctly imported the header files..

Thanks,

Jack

回答1:

Assuming the libraries with these functions are included in the Xcode project, this error occurs when the libraries are not linked with the binary executable file. This can happen when upgrading an older project to a newer version of Xcode.

To fix it navigate to the project overview in Xcode. Click on the target. Click on Build Phases. Expand the "Link Binary With Libraries" list. If libraries are not listed, click the "+", and add the appropriate libraries.



回答2:

You are missing a library/framework which caused the linker errors that you see. I'm not sure which framework is associated with Facebook functionality, it might be the general network related one. Let me see if I can find out which you need.

EDIT: Do you have the Foundation framework included with your project? Does the Facebook site maybe mention which one you need?



回答3:

I don't work with facebook, but here's my thoughts: That's a linker error, not a compiler one (which it would be if the header weren't imported). Have you imported the correct framework? And ensured XCode is telling the compiler to link to the correct library?



回答4:

Its related to linker error. So just remove facebook framework from project and drag new one.

  • Remove existing facebook framework
  • Drag FacebookSDK.framework folder from the SDK installation folder into the Frameworks section of your project