2

So I'm not sure if this is an issue with Unity or with the Facebook Unity SDK, or something I might be doing? It only started appearing recently, it was working perfectly fine up until I had to update Unity for iOS9 font issues.

The point at which it crashes in Xcode is:

+ (instancetype)instanceWithRequestID:(int)requestID
{
    FBUnitySDKDelegate *instance = [[FBUnitySDKDelegate alloc] init];
    instance->_requestID = requestID;
    [g_instances addObject:instance];  // Breaks on this line. instance is nil
    return instance;
}

And the code I am using for the AppRequest is

public void RequestLivesFromFriends(string[] friendIds)
{
    if(!FB.IsLoggedIn)
    {
        LoginToFacebook ();
        return;
    }
    FB.AppRequest(
        "Please send me a life!",
        Facebook.Unity.OGActionType.ASKFOR,
        livesIdValue,
        friendIds,
        "RequestLife",
        "Request a life from your friends",
        requestLifeCallback
        );
}

Is there currently an issue with the SDK's? Or am I just doing something wrong?

Sospitas
  • 58
  • 4
  • 1
    Which version of Unity and Facebook Unity SDK are you using? – JeanLuc Nov 10 '15 at 23:27
  • Sorry I took so long to reply. Unity is currently 5.2.2f1 and Facebook is 7.2.2 – Sospitas Nov 11 '15 at 09:52
  • from what Version of Unity did you update ? – JeanLuc Nov 12 '15 at 08:24
  • 5.0.2f1. I actually did a test yesterday where I made an entirely clean project, and the Facebook Friend Selector works perfectly fine in that project. Switching out my customised selector in the actual project for the built in one still leads to crashes, so there must be something funky with my project sadly – Sospitas Nov 12 '15 at 10:33

1 Answers1

0

Well, I found the solution myself in the end.

I had -fno-objc-arc set as the Compiler Flag on FBUnitySDKDelegate.m

Apparently, having that on with the more recent versions of the SDK (or maybe something else was causing it, I'm not exactly sure) causes the NSMutableArray g_instances to be converted to an NSString. So when the code tries to add the FBUnitySDKDelegate object 'instance' to g_instances, it is trying to call addObject on an NSString, passing in an FBUnitySDKDelegate, which obviously doesn't work.

So yeah, if you have this problem, check for Compiler Flags on the file.

Sospitas
  • 58
  • 4
  • Can you explain what file did you edit ? im confused , having the same problem thanks. – LumbusterTick Dec 02 '15 at 09:08
  • It's not actually a file. In Xcode, when you click on your project, at the top there should be a "Build Phases" tab. If you click on that, and then click on Compile Sources, a list of files should open up. I had -fno-objc-arc on anything that was in an iOS folder (directory ended with /ios). I just had to remove it from the FBUnitySDKDelegate.m and it started to work. – Sospitas Dec 02 '15 at 14:18
  • ok so i put the -fno-objc-arc on all the ios files except FBUnitySDKDelegate.m? – LumbusterTick Dec 02 '15 at 15:03