Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing apps for multiple iOS version

I am testing an app on an iPhone 4 with iOS 5.1 and an iPad 4 with iOS 6.0. I looked around and surprisingly did not find similar questions:

1- My app has some methods that have been deprecated in iOS 6.0 so I believe I have to build some if/then conditions to test for system version using: [[UIDevice currentDevice] systemVersion], and then use the version appropriate methods. Is that the most efficient way?

2- My understanding is, with only one target, the "project" Deployment Target and the "Targets" deployment target serve the same purpose. And I need to have one of them or both as iOS 5.1 since that is the minimum iOS supported. What is confusing is that if the target is built based on iOS 5.1, how would it run on the iPad4 with iOS 6.0:

  • Does the iPad OS checks for target versions before running or just tries to run the code and it happens that the iOS 5.1 target does not have any code that the 6.0 is incompatible with?

  • Even if that is the case though, how could a 5.1 target support 6.0 methods that I built to conditionally replace deprecated methods?

Many thanks!

like image 893
Khaled Barazi Avatar asked Nov 16 '12 16:11

Khaled Barazi


People also ask

Can I have two versions of an app on iPhone?

No, it's not possible to install two versions of an app that has the same name. You'd have to ask the developer to rename it, which I doubt he'll be willing to do. Although the iOS doesn't really check “the name” (like a file manager would do), the develop would have to create another “build” if I am not mistaken.

How do I merge iOS apps?

Create foldersTouch and hold the Home Screen background until the apps begin to jiggle. To create a folder, drag an app onto another app. Drag other apps into the folder. You can have multiple pages of apps in the folder.

How do I install paid apps on multiple iOS devices?

An easy way to get paid apps onto all of your compatible devices is to use the automatic download settings built into iOS. With that turned on, any new app you buy is automatically installed on all your compatible devices. Tap the Settings app. Scroll to and choose iTunes & App Store.

Can Apple have multiple developer accounts?

You can have multiple Apple IDs and multiple developer accounts if you work for multiple organizations. Or you can use one Apple ID for everything, or one for your personal apps and one for your professional apps.


1 Answers

Deprecated methods

Deprecated methods can be used if you are targetting iOS versions that were released before those methods were deprecated. But assuming your deployment target is set correctly, you won't get any compiler errors unless those deprecated methods were always deprecated for the versions you are targetting. In other words, if you are seeing deprecation warnings in your code you need to fix them or check that your deployment target setting is correct. Do not ignore them!

Xcode setting levels

You mention the fact that you can define the deployment target setting at both the target and project level. Xcode build settings at the target level will override project settings. So define the deployment target at one of these levels only, then go to the other and hit delete so you don't have duplicate values. If you only have one target then it doesn't really matter if you define it at the target or project level.

Backwards and forwards compatibility

Finally, there are many factors that come into play for backwards and forwards compatibility. Sometimes there will be new iOS 6 methods like supportedInterfaceOrientations which will simply be ignored on older iOS versions. Other times you need to add explicit checks:

  • If you are calling a method on an object and that method was only introducted with iOS 6, you will need to add a respondsToSelector: check like this:

    // only available on iOS 6
    if ([locationManager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)]) {
        locationManager.pausesLocationUpdatesAutomatically = YES;
    }
    
  • If you want to check if a particular class exists on the current iOS version, you can check the return value of the +class method like this:

    // Only available on iOS 6
    if ([UICollectionView class]) {
        // ...
    } else {
        // class doesn't exist in this iOS version
    }
    
  • If you want to check if a particular function is available, do a simple if statement on it:

    // Only available in iOS 6
    if (ABAddressBookCreateWithOptions) {
        ABAddressBookCreateWithOptions(...);
    } else {
        ABAddressBookCreate(...);
    }
    
  • Finally, if you want to check if a constant is available, check it's address:

    // Only available in iOS 4
    if (&UIApplicationProtectedDataDidBecomeAvailable) {
        // subscribe to notification
    }
    

Your Base SDK setting should always be set to "latest".

If you follow all these guidelines you will be able to solve most of your problems without having to add explicit version checks. Checking the iOS version or device ID is very brittle and is likely to cause your app to break in future versions. You really want to avoid it.

like image 169
Mike Weller Avatar answered Oct 16 '22 15:10

Mike Weller