xcodexcode4.6

How to add Social Framework in Xcode project?


Just starting to learn Xcode and for this lesson I'm supposed to add the Social Framework in Xcode as to add Twitter composer features.

So I'm following the steps in the book:

  1. I select my project and my target and go to Build Phrases.
  2. I open Link Binary with Libraries and click the + sign
  3. I look for Social Frameworks and click on Add
  4. I now can see Social Frameworks beneath my project
  5. Then I'm supposed to go to my .m file and add this code:

Code:

SLComposeViewController *composer = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
[composer setInitialText:self.tweetTextView.text];
[self presentViewController:composer animated:YES completion:nil];

It then shows 3 error signs saying : 'Use of undeclared Identifier: SLComposeViewController'. And the project won't build.

Have I done something wrong?


Solution

  • You simply need to add:

    #import <Social/Social.h>
    

    to the top of your .m file where you're using Social framework API's.

    I also did a chat.stackoverflow.com presentation on the Social framework and that transcript is here, and a sample project can be found on github.