swiftxcode6facebook-sdk-3.14.x

FBRequestConnection.startWithGraphPath crashes swift


I'm using the Facebook SDK to get users profile data in swift, but calling FBRequestConnection.startWithGraphPath:completionHandler: is crashing swift.

I'll leave what I think is the relevant part of the log

1.  While type-checking 'profile' at /Users/fratelli/Documents/Projects/Wink/Wink/OAuthFacebookSession.swift:118:14
2.  While type-checking expression at [/Users/fratelli/Documents/Projects/Wink/Wink/OAuthFacebookSession.swift:139:9 - line:142:9] RangeText="FBRequestConnection.startWithGraphPath(
            self.readPermissions(),
            completionHandler: completionHandler
        )"
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: swift frontend command failed due to signal (use -v to see invocation)
Command /Applications/Xcode6-Beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 254

I already filled a bug report. Now, besides using Objective-c, I don't see any other way around this. What I would like to know is if there's any other FB SDK method that I could try that achieves the same effect.

Here's the code:

    var completionHandler = {
        connection, result, error in
    } as FBSessionStateHandler;

    // Request the profile info
    FBRequestConnection.startWithGraphPath(
        "me?fields=birthday,gender,first_name,last_name,name_format,picture",
        completionHandler: completionHandler
    );

Solution

  • In the end, I had to use Objective-c. So I created a OAuthFacebookWrapper.h file

    #import <Foundation/Foundation.h>
    #import <FacebookSDK/FacebookSDK.h>
    
    @interface OAuthFacebookWrapper : NSObject
    
    + (void) startWithGraphPath:(NSString *)graphPath completionHandler:(FBRequestHandler)handler;
    
    @end
    

    Then OAuthFacebookWrapper.m

    #import "OAuthFacebookWrapper.h"
    
    @implementation OAuthFacebookWrapper
    
    + (void) startWithGraphPath:(NSString *)graphPath completionHandler:(FBRequestHandler)handler
    {
        [FBRequestConnection startWithGraphPath: graphPath completionHandler: handler];
    }
    
    @end
    

    Calling that method with the same arguments as before works.