iPhone: Manage frameworks according to ios version

2019-08-13 19:02发布

问题:

In my iPad App,

I have done coding for twitter.

For ios version 4.0,4.1,4.2 and 4.3.

And

ios version 5.0.

I have done separate coding for twitter.


if([[[UIDevice currentDevice] systemVersion] floatValue]>=5.0)

like this.

The problem is when I run the code in ios 4.x it crashes

with result could not load the twitter framework that I include in XCode.

So, How do I manage this frameworks in my app.

It's Deployement Target is 4.0.

It's Base SDK is 5.0.

回答1:

You must check that the Twitter.framework is linked "optional". Go to You Target, choose "Bild Phases", select "Link Binary With Libraries" and selection "Optional" at the Twitter.framework.

Check screenshot:

The in you code, you can check if the Twitter Framework is here by calling:

if(NSClassFromString(@"TWRequest") != NULL) {
  // Yes. Twitter Framework loaded
}