unwise guy
unwise guy

Reputation: 1128

Twitter Framework for iOS - Why does TWrequest.h import <Social/SLRequest.h>?

Inside of TWRequest.h that's inside of the Twitter Framework, there it imports this

#import <Social/SLRequest.h>

But TWRequest was built for iOS 5, so why would it import the Social Framework's file since those are for iOS 6?

I'm getting this error..

'Social/SLRequest.h' file not found

Of course it's not found because I didn't add in the Social Framework because I want to use the Twitter Framework. I can't simply remove it because that file is referencing from the Social framework, how can I fix this? Thanks

Upvotes: 0

Views: 1228

Answers (2)

unwise guy
unwise guy

Reputation: 1128

This seemed more of an xcode problem. Sometimes it worked and sometimes it threw the error. I had to exit xcode and restart for it to work again. It eventually fixed itself.

Upvotes: 0

Yuri
Yuri

Reputation: 459

In iOS 6 the Twitter framework methods are deprecated. Instead you should use the Social.framework. Which includes sharing both Twitter and Facebook.

The sample code checks what the OS version is running and what framework classes are available whether it iOS 5 - Twitter.framework or 6 - Social.framework

#import <Twitter/Twitter.h>
#import <Social/Social.h>


- (void) postTweet {
NSString *someTweet = @"someTweet";

// running on iOS5
if (NSClassFromString(@"TWTweetComposeViewController") && [TWTweetComposeViewController canSendTweet]) {

    TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];

    [tweetSheet setInitialText:someTweet];
    [self presentModalViewController:tweetSheet animated:YES];

    // running on iOS6
} else if ( NSClassFromString(@"SLComposeViewController") && [SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter] ) {

    SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

    [tweetSheet setInitialText:someTweet];
    [self presentViewController:tweetSheet animated:YES completion:NULL];
}
}

Upvotes: 1

Related Questions