简体   繁体   中英

How can I verify whether my app supports iOS 4.3 or not

I compiled my app with sdk 6.1 and set the deployment target to iOS 4.3. Does this mean that my app can run on 4.3? I don't have such device and can't actually test it but I would like to know if the app would work on 4.3.

Setting the deployment target to iOS 4.3 ensures your app supports iOS 4.3 and above unless you are not using any features that only supports in higher versions like ARC, Storyboard, autolayout . It is better to test on a device or simulator. You can download the iOS4.3 simulator through Xcode

Xcode-> preferances -> downloads -> iOS 4.3 simulator

if you feel that the class which you have used might not be available in the other ios version then you can check the same using

Using the NSClassFromString function. Pass the name of your class to this method as a string.

If the return value of this function is nil, that class is not available on the device that runs your app;

otherwise, that class is available on the device and you can go ahead and use it as you wish.

Here is an example:

i am checking for NSJSONSerialization class, similarly you can check for your class also,

if (NSClassFromString(@"NSJSONSerialization") != nil) {
 /* You can use this class */

     [NSJSONSerialization JSONObjectWithData:... /* Put data here */
                      options:...           /* Put options here */ 
                       error:...];        /* Handle errors here */
} else {
     /* That class is not available */
}

You can run on any device whose iOS version is greater then or equal to the deployment target set by you.

So keep in mind you have not used any framework or features that are not supported in that version.

Hope it helps you.

You can always test your app on 4.3 simulator. Select the iPhone 4.3 Simulator under the "Scheme" menu (you can find it on the right side of the "Run" "Stop" button on top of Xcode). If you cant find the option for 4.3 simulator then you need to download it by going to Xcode->Preference->Downloads->Components->iOS 4.3 Simulator

Sometimes the xcode will not complain about the usage of new features (like autolayout, etc) available in 6.1 but will crash the app when run on 4.3.

test in this way is a solution that works pretty well, but it is not 100% guaranteed

/**
 * Example usage:
 *   If you want to see if you're using methods that are only defined in iOS 4.0 and lower 
 *   then you would use the following. Replace the __IPHONE_4_0 with whatever other macro 
 *   you require. See Availability.h for iOS versions these relate to.
 * 
 * YourProjectPrefixHeader.pch:
 *   #define __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED __IPHONE_4_0
 *   #import "ThisFile.h"
 *   
 *   // The rest of your prefix header as normal
 *   #import <UIKit/UIKit.h>
 */

#import <Availability.h>

#define __AVAILABILITY_TOO_NEW __attribute__((deprecated("TOO NEW!")))

#ifndef __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED
#define __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED __IPHONE_OS_VERSION_MIN_REQUIRED
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_OS_VERSION_MIN_REQUIRED
#error You cannot ask for a soft max version which is less than the deployment target
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_2_0
#undef __AVAILABILITY_INTERNAL__IPHONE_2_0
#define __AVAILABILITY_INTERNAL__IPHONE_2_0 __AVAILABILITY_TOO_NEW
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_2_1
#undef __AVAILABILITY_INTERNAL__IPHONE_2_1
#define __AVAILABILITY_INTERNAL__IPHONE_2_1 __AVAILABILITY_TOO_NEW
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_2_2
#undef __AVAILABILITY_INTERNAL__IPHONE_2_2
#define __AVAILABILITY_INTERNAL__IPHONE_2_2 __AVAILABILITY_TOO_NEW
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_3_0
#undef __AVAILABILITY_INTERNAL__IPHONE_3_0
#define __AVAILABILITY_INTERNAL__IPHONE_3_0 __AVAILABILITY_TOO_NEW
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_3_1
#undef __AVAILABILITY_INTERNAL__IPHONE_3_1
#define __AVAILABILITY_INTERNAL__IPHONE_3_1 __AVAILABILITY_TOO_NEW
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_3_2
#undef __AVAILABILITY_INTERNAL__IPHONE_3_2
#define __AVAILABILITY_INTERNAL__IPHONE_3_2 __AVAILABILITY_TOO_NEW
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_0
#undef __AVAILABILITY_INTERNAL__IPHONE_4_0
#define __AVAILABILITY_INTERNAL__IPHONE_4_0 __AVAILABILITY_TOO_NEW
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_1
#undef __AVAILABILITY_INTERNAL__IPHONE_4_1
#define __AVAILABILITY_INTERNAL__IPHONE_4_1 __AVAILABILITY_TOO_NEW
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_2
#undef __AVAILABILITY_INTERNAL__IPHONE_4_2
#define __AVAILABILITY_INTERNAL__IPHONE_4_2 __AVAILABILITY_TOO_NEW
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_4_3
#undef __AVAILABILITY_INTERNAL__IPHONE_4_3
#define __AVAILABILITY_INTERNAL__IPHONE_4_3 __AVAILABILITY_TOO_NEW
#endif

#if __IPHONE_OS_VERSION_SOFT_MAX_REQUIRED < __IPHONE_5_0
#undef __AVAILABILITY_INTERNAL__IPHONE_5_0
#define __AVAILABILITY_INTERNAL__IPHONE_5_0 __AVAILABILITY_TOO_NEW
#endif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM