Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Facebook SDK on Unity 5

Discussion in 'iOS and tvOS' started by Nerosam, Mar 12, 2015.

  1. Nerosam

    Nerosam

    Joined:
    Jul 23, 2013
    Posts:
    40
    Hi everyone,

    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 as follows:-

    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
     
  2. blitzred2

    blitzred2

    Joined:
    Jan 8, 2015
    Posts:
    3
    Hello Nerosam,

    I am getting a similar issue with facebook sdk from upgrading to unity 5.0.0f4 from untiy 4.6.2f1. Mine will either stop where yours is stoping, but sometimes mine breaks in a different location of display manager.

    Screen Shot 2015-03-12 at 4.29.50 PM.png
    with facebook sdk version 6.2.1. Now with facebook sdk version 6.2 it always stops where yours does. This is on start up of my app it crashes.

    EDIT: I am also getting this error with AdColony sdk version in a base project in untiy 5.0.0f4, which worked in untity 4.6.3f1.
     
    Last edited: Mar 23, 2015
  3. blitzred2

    blitzred2

    Joined:
    Jan 8, 2015
    Posts:
    3
    I just got a fix for this issue.
    I had to add the flag -fno-objc-arc to certain files.
    To add it got to Targets -> Build Phases -> Compile Sources
    - FbUnityInterface.mm
    - UnityADC.mm - I know for adcolony not sure if need for facebook
    - AppStorDelegate.mm

    Now that fixed the issue, but I do not know all of the conqueses of doing this. This replaces the step of turning off all objc arc to the thing.
     
    Nerosam likes this.
  4. TheMax2015

    TheMax2015

    Joined:
    Mar 6, 2015
    Posts:
    12
    Hia blitzred2,

    I am getting the same issue with Facebook SDK and just wanted to check on your solution as, have you also downgraded to Facebook SDK 6.2 and when you compile for IOS which version of the XCODE SDK are you using.

    As at this stage I am getting the apple mach-o linker error, I am still running 6.2.1 Facebook SDK and running Xcode 6.1 with Unity version 5.0.0f4

    Thanks

    Max
     
  5. RMagiko

    RMagiko

    Joined:
    Jul 19, 2013
    Posts:
    4
    I've fixed this error marking 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

    I'm using Unity 5.0.1f and Facebook SDK 6.2.1.

    Hope it helps.
     
    Modismos and Nerosam like this.
  6. chenklein2854

    chenklein2854

    Joined:
    Dec 30, 2014
    Posts:
    2


    Hey RMagiko

    Can you please explain your fix? ,where and how do i choose "IOS" as platform for plugin and how to edit FbUnityInterface.mm in order to add "-fno-objc-arc" as compile flag ?

    thank you !
     
  7. Nerosam

    Nerosam

    Joined:
    Jul 23, 2013
    Posts:
    40
    select the file in unity, in the inspector, choose ios tick box and set compile flag/text in ios section
     
    RMagiko likes this.
  8. Nerosam

    Nerosam

    Joined:
    Jul 23, 2013
    Posts:
    40
    Can confirm that this works for me. Thanks.
     
    RMagiko likes this.
  9. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,874
    Confirmed that this works also with patch 5.0.1p3. Note that you must only tick iOS platform on the list for this file (remove Editor).