简体   繁体   中英

Facebook SDK v4 & Parse (Swift)

I am trying to work ParseFacebookUtilsv4 & FacebookSDK v4.. After many trials, I've managed to reduce the errors to 1.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    Parse.setApplicationId("###",
        clientKey: "###")

    PFFacebookUtils.initializeFacebookWithLaunchOptions(launchOptions)

}

In this part, which is exactly copied from Parse's iOS Docs - Facebook Setup (that is updated yesterday for FBSDKv4), I am getting an error:

'PFFacebookUtils.Type' does not have a member named 'initializeFacebookWithLaunchOptions'

When I check the full documentation of ParseFacebookUtilsv4 which says ~ Warning: This class supports official Facebook iOS SDK v4.0+ and is available only on iOS. ~, I saw that there isn't any class called 'initializeFacebookWithLaunchOptions' ; instead there is 'initializeFacebookWithApplicationLaunchOptions:'

However, when I change my AppDelegate.swift / didFinishLaunchingWithOptions part as:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    Parse.setApplicationId("###",
        clientKey: "###")

    PFFacebookUtils.initializeFacebookWithApplicationLaunchOptions(launchOptions)

}

...I get an error saying 'Missing return in a function expected to return 'Bool'. Then I tried to add both

 return true /* AND */ return false // at the end of the function; 

...I get 9 crashes such as: i.stack.imgur.com/o989R.png

I am completely stuck and don't know how to fix this.

[PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:launchOptions]; //works

[PFFacebookUtils initializeFacebookWithLaunchOptions:launchOptions]; //does not compile or work

The first line above worked for me. Seems like they have forgotten to update their documentation.

you should go to your PFFacebookUtils.h in the PFFacebookUtils.h header file and change:

(void)initializeFacebookWithApplicationLaunchOptions:(NSDictionary *)launchOptions;

To:

(void)initializeFacebookWithApplicationLaunchOptions:(PF_NULLABLE NSDictionary *)launchOptions;

it will work ! references https://developers.facebook.com/bugs/1462780714012820/

Based on your error logs, I think either you're missing dependencies, or you have dependencies added here but you haven't included them in your project.

I think your Facebook SDK isn't included in the build target, since the symbols that are missing have FB prefixes.

Found my answer: I had to import FBSDKLoginKit in my bridging header (which was not mentioned in the recently updated Parse Doc).

So my bridging-header looks like:

    #import <FBSDKCoreKit/FBSDKCoreKit.h>
    #import <FBSDKLoginKit/FBSDKLoginKit.h>
    #import <ParseFacebookUtilsV4/PFFacebookUtils.h>
    #import <Parse/Parse.h>
    #import <Bolts/Bolts.h>

I was having the same issue and had to implement two of the suggestions above to get my app to run with out issue.

First i added the FBSDKLoginKit from the FB SDK and imported it.(Thanks senty)

#import <FBSDKLoginKit/FBSDKLoginKit.h>

Then i replaced:

[PFFacebookUtils initializeFacebookWithLaunchOptions:launchOptions];

with:

[PFFacebookUtils initializeFacebookWithApplicationLaunchOptions:launchOptions];

Hope my answer is helpful.

I had had the same problem with FB SDK v4 + Parse v1.7.5 SDK.

Finally, I solved this problem on my project. There is a mistake from the Parse blank project. Don't use Parse blank project.

https://www.parse.com/docs/downloads/ It is the official download page and there are two types download(v 1.7.5), which is SDK or Blank Project, to start project.

It is only working with Parse SDK files + your new project! Please import just only SDK.

尝试删除ParseFacebookUtils (只需保留ParseFacebookUtilsV4 ),它会产生一些冲突。

If you are using FB SDK v4 + Parse v1.7.5 SDK,

I only have:

#import <ParseFacebookUtilsV4/PFFacebookUtils.h>

in my bridging header. My AppDelegate.swift file now contains:

import Parse
import Bolts
import FBSDKCoreKit
import FBSDKShareKit
import FBSDKLoginKit

and I'm able to run my app successfully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM