App crashes on ios 4.X for framework Twitter.framework

http://stackoverflow.com/questions/8641864/app-crashes-on-ios-4-x-for-framework-twitter-framework


I am using twitter using Sharekit and for IOS5, I am using its classTWTweetComposeViewControllerClass as,

Class TWTweetComposeViewControllerClass = NSClassFromString(@"TWTweetComposeViewController");

    if (TWTweetComposeViewControllerClass != nil) {
        if([TWTweetComposeViewControllerClass respondsToSelector:@selector(canSendTweet)]) {
            UIViewController *twitterViewController = [[TWTweetComposeViewControllerClass alloc] init];

            [twitterViewController performSelector:@selector(setInitialText:) 
                                        withObject:NSLocalizedString(@"TwitterMessage", @"")];



            [self.navigationController presentModalViewController:twitterViewController animated:YES];
            [twitterViewController release];
        }
    } else {
        [SHK flushOfflineQueue];
        SHKItem *item = [SHKItem text:text];
        //[SHKTwitter shareItem:item];
        SHKActionSheet *actionsheet = [SHKActionSheet actionSheetForItem:item];
        [actionsheet showFromToolbar:self.navigationController.toolbar];
    }

It is working fine with simulator 5.0 but crashes on 4.3 with below error.

dyld: Library not loaded: /System/Library/Frameworks/Twitter.framework/Twitter
      Referenced from: /Users/indianic/Library/Application Support/iPhone Simulator/4.3.2/Applications/241167D0-62E0-4475-85FD-0B8253B4E456/demoFBTW.app/demoFBTW
      Reason: image not found

How do I fix this. I tried to change the dependency for the framework from Required to Optional but didn't find for that

link | improve this question

 
Twitter.framework only possess support in ios 5 not in ios4 –  iPhone  Dec 27 '11 at 6:47
 
So i wont be able to use TWTweetComposeViewControllerClass for app which is using both ios5 and ios4? Because I am using sharekit for <ios5 –  Roshni  Dec 27 '11 at 6:48
 
"...but didn't find for that". What do you mean by "didn't find for that"? Do you mean you couldn't find the option in Xcode? –  Firoze Lafeer  Dec 27 '11 at 7:06
 
yes i didn't find dependency option for framework –  Roshni  Dec 27 '11 at 7:08
 
I am finding for weak linking –  Roshni  Dec 27 '11 at 7:10
show 2 more comments
feedback

1 Answer

up vote 0 down vote accepted

It looks like you found how to weak link the framework. Assuming you are using Xcode 4.2 and LLVM3, you can also simply this code a bit and fix a bug you have while you're at it:

#include <Twitter/Twitter.h>

// This line is no longer needed:
// Class TWTweetComposeViewControllerClass = NSClassFromString(@"TWTweetComposeViewController");


// this part can now be:
if ([TWTweetComposeViewController class] != nil) { // no need to look up class by string now

    // note previously you were checking if this class responds to 'canSendTweet'
    // but you never called the method to see if you can actually send the tweet

    if([TWTweetComposeViewController canSendTweet]) {

        // you can type this correctly now...
        TWTweetComposeViewController *twitterViewController = [[TWTweetComposeViewController alloc] init];

        // ... and call this method directly
        [twitterViewController setInitialText:NSLocalizedString(@"TwitterMessage", @"")]; 

        [self presentModalViewController:twitterViewController animated:YES];

        [twitterViewController release];
    }
}
... continue with the shareKit option
link | improve this answer
 
Was this post useful to you?      

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值