Search code examples
iosxcodefacebookunity-game-enginefacebook-unity-sdk

Facebook SDK on Unity 5 on iOS


I have been having trouble getting the latest Facebook SDK 6.2.1 to function with Unity 5.0.0f4 in both my project and an empty one.

Here is what I do:-

  1. Create a blank project
  2. import Facebook SDK
  3. Set App ID and Name in editor settings
  4. Add sample scene to build settings
  5. Build Xcode Project
  6. Open in Xcode
  7. Disable ARC in settings
  8. Remove extra #endif when xcode complains about it
  9. Build and Run game on iOS device

The error I end up with is in the following link:-

dl.dropboxusercontent.com/u/13490919/FacebookiOSProb/Screenshot%202015-03-12%2014.53.29.png

The error I get is "EXC_BAD_ACCESS (code=1)". I'm not much of an xcode/iOS guy so this confuses me a tone load. This error does not occur if facebook isn't present. Has anyone got any idea how to get around this? Surely i'm not the only one with this issue. All I want to do is get an access token from facebook. If need be, I don't mind using a simple webview or something similar.

Any help on this would be much appreciated. I would give free hugs to but ya know.

Thanks


Solution

  • Ive managed to solve the issue. As posted by someone else on unity forums here, you need to mark the option "iOS" as platform for plugin and adding "-fno-objc-arc" as compile flag in the following file: Assets/Facebook/Editor/iOS/FbUnityInterface.mm

    This works with the latest versions of Unity 5.0.1f and Facebook SDK 6.2.1 as of this post.