Can I build a Universal App that's targeted for different OS versions on each device?

StackOverflow https://stackoverflow.com/questions/18097279

  •  23-06-2022
  •  | 
  •  

Domanda

I want to make a Universal app, for iPhone supporting iOS 5 and for iPad but supporting iOS 6 and later

Is it possible to do this with the same Xcode project/app build?

I want to use UICollectionView with UICollectionViewWaterfallLayout in the iPad version, which requires iOS 6 or later.

È stato utile?

Soluzione

It is not possible since deployment target is intended for both devices; iPhone as well as iPad. If you will set it to 5.0, both will support least iOS 5.0. You can't set it for individual.

If you want to set out completely different layout, then while loading controller, you can check device's iOS version and type of device. You have to make to different viewcontrollers for that.

e.g.

if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0") && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        //load controller with UICollectionView layout
    }
else

{
//load simple layout controller
}

Above macro was referenced from following. Grab them as they are very useful for whole app. Write them in .pch file.

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)

#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)

#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

Altri suggerimenti

You can use both the things in a single application by putting a check on the os versions by using some macros like below

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

So you will be using it like

if(SYSTEM_VERSION_LESS_THAN(@"6.0")){
    //Do your stuffs that supports below 6.0
}else if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")){
    //Do your stuffs that supports => 6.0
}

I hope this will you. Thanks.

It's not possible. You can only define one base SDK and one deployment target for an App.

In simple word, NO it is not possible.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top