4
votes

I understand that there have been similar posts about this issue, but nothing seems to be working.

I'm trying to enable my users to sign-up/in with Facebook, but I am having trouble getting the Facebook SDK working.

I have added the 'FBSDKCoreKit.Framework' framework as the Facebook guide says to do, as well as the 'ParseFacebookUtils.framework'. When I try and initialize facebook in my AppDelegate.swift, here..

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) ->  Bool {
           Parse.setApplicationId("", clientKey: "")

   PFFacebookUtils.initialize()

   return true

I get the error that says "Use of unresolved identifier 'PFFacebookUtils'". I followed all the steps under 'Setup' in the Parse Docs.

This is all in Swift, and so here is my Bridging Header File...

//  Use this file to import your target's public headers that you would like to expose to Swift
#import <Parse/Parse.h>
#import <ParseUI/ParseUI.h>
#import <Bolts/BFTask.h>
#import <ParseFacebookUtils/PFFacebookUtils.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>

What am I doing wrong? Very frustrated, but I will eventually figure it out.

4
If you make a new Objective-C file and put it in your bridging header, can you use stuff declared in that Objective-C file? It's possible your bridging header file isn't set up correctly in your project. - nhgrif
Hi @justColbs have you been able to resolve this? - Vakas

4 Answers

8
votes

From what I think, you might have used ParseFacebookUtilsV4.Framework (which is the latest support for Swift I am assuming) instead of ParseFacebookUtils.Framework (old or may be the one that requires objective C bridging headed).

So if you want your app to work as per the code you have, use the ParseFacebookUtils.Framework and avoid ParseFacebookUtilsV4.Framework. But if you want to use ParseFacebookUtilsV4.Framework, you have to do some changes in your swift Appdelegate:

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

func applicationDidBecomeActive(application: UIApplication) {
  FBSDKAppEvents.activateApp()
}

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
  return FBSDKApplicationDelegate.sharedInstance() .application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}

Bridging header changes:

#import <FBSDKCoreKit/FBSDKCoreKit.h>

Not sure about the Utils import, but if needed, replace the old import code #import ParseFacebookUtils/PFFacebookUtils.h in your bridging header with this one

#import <ParseFacebookUtilsV4/PFFacebookUtils.h>

Notice the small change with addition of V4.

I hope I may have helped you in someway.

11
votes

Try this:

import Bolts
import ParseFacebookUtilsV4
import FBSDKCoreKit
import FBSDKLoginKit
3
votes

Make sure you've set your bridging header correctly.

If you click your project in the "Project Navigator", then click your target, click Build Settings, and scroll down to "Swift Compiler - Code Generation", you should see a row for Objective-C Briding Header.

In this row, you need to enter your bridging header:

enter image description here

ProjectName/Your-Bridging-Header.h

3
votes

This happened to me when I enabled frameworks in cocoapods (use_frameworks!) -- once I added "import ParseFacebookUtilsV4" Xcode was able to find PFFacebookUtils.