Reputation: 1439
I'm trying to install the Facebook iOS SDK in my Obj-C project, but it appears as though the FacebookSDK is only written in Swift now? Anyone have any ideas or tips on how I can integrate the Facebook SDK with my Obj-C project? Installing via CocoaPods.
Help is appreciated!
Upvotes: 0
Views: 518
Reputation: 1
You can still use the Facebook iOS SDK in your Objective-C project, even though it’s primarily written in Swift now. I recommend using Swift Package Manager (SPM) for the integration, as CocoaPods is deprecated. Here’s how to do it:
Add Facebook SDK via Swift Package Manager:
File > Add Packages...
.https://github.com/facebook/facebook-ios-sdk
FBSDKCoreKit
and FBSDKLoginKit
.Set up a Bridging Header:
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
Use Facebook SDK in Objective-C:
In your AppDelegate.m
, for example:
[[FBSDKApplicationDelegate sharedInstance] application:application
didFinishLaunchingWithOptions:launchOptions];
Alternatively, you can still use CocoaPods if you prefer, but it's deprecated. Add pod 'FacebookSDK'
to your Podfile
and run pod install
. However, I recommend using SPM for long-term support.
This response addresses the question more directly while providing both options.
Upvotes: 0