Implementing Facebook into Xcode Project

16,266

Solution 1

If you are not familiar with git you can download the sdk manually to your hard drive on this page: https://github.com/facebook/facebook-ios-sdk click on downloads and select the preferred format.

On the readme clearly states how to add the library to your own application:

If you want to integrate Facebook with an existing application, then follow these steps:

  • Copy the Facebook SDK into your Xcode project:

    • In Xcode, open the Facebook SDK by selecting File->Open... and selecting src/facebook-ios-sdk.xcodeproj.
    • With your own application project open in Xcode, drag and drop the "FBConnect" folder from the Facebook SDK project into your application's project.
    • Include the FBConnect headers in your code:

      #import "FBConnect/FBConnect.h"

    • You should now be able to compile your project successfully.

  • Register your application with Facebook:

    • Create a new Facebook application at: http://www.facebook.com/developers/createapp.php. If you already have a related web application, you can use the same application ID.
    • Set your application's name and picture. This is what users will see when they authorize your application.

You should have a file called yourProjectNameAppDelegate.h and yourProjectNameAppDelegate.m.

You have to put #import "FBConnect/FBConnect.h" into yourProjectNameAppDelegate.h. And declare a variable in the header Facebook* facebok; and also synthesize it.

Your yourProjectNameAppDelegate.m contains a method called application:didFinishLaunchingWithOptions: which should look like:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
   facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID"];
   [facebook authorize:permissions delegate:self];

}

Also put in this file the other method.

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
    return [facebook handleOpenUrl:url];
}

Also I suggest to learn a bit more about objective-c, because your problems are not related to the facebook library. You can find plenty of resources on the net. I suggest to look this iTunes university screencast.

Solution 2

for github, go to http://help.github.com/ they have loads of resources to help you out, but you pretty much just need to type git clone , and then find where it has put the repository.

alternatively if you browse to the repo on the github website, you should be able to just click a download button.

with the second bit, what do you need help with?

the app id will be from when you have set your application up in facebook.

Share:
16,266
PatrickGamboa
Author by

PatrickGamboa

Updated on August 31, 2022

Comments

  • PatrickGamboa
    PatrickGamboa over 1 year

    I am going to be implementing the facebook application into my project, but I've ran into some roadblocks. First I read about the link that developers.facebook.com has posted: enter image description here

    I really don't know how to use the GitHub repository and add it to my app project, so I hope I can get some help with that,

    Next, while I was continuing the rest, I found something that I might need help on as well: enter image description here

    So that's all I have for now, I just need to get through this first part, then I can continue on, so I hope someone can help me get on through that first part, thanks

    (sorry if I had to post the pictures, I just really need to be specific and I'm sometimes having trouble with reading tutorials)