Question

I've my iPhone project on the xCode 4.3.2 and it works well. It uses NSUbiquitousKeyValueStore class and it's base SDK is iOS 5.0. Now I am going to build my project on the xCode 3.2.5 and it says error "Undefined symbol NSUbiquitousKeyValueStore". Of course, I know NSUbiquitousKeyValueStore class is supported from iOS 5.0 and xCode 3.2.5 didn't supported iOS 5.0. So I want to disable these features older the iOS 5.0, and enable over the iOS 5.0. How can I do this?

Was it helpful?

Solution

Surround the code which makes use of features that were introduced with the 5.0 SDK like so:

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 50000
    // Code using NSUbiquitousKeyValueStore goes here
#endif

Note that this is conditional compilation. The test is performed when building, not when running. So, if you build in an older version of Xcode without the 5.0 SDK, then the resulting program will never use NSUbiquitousKeyValueStore, no matter where you run it. There is no feasible way to build against an older SDK and yet still use feature of the newer SDK if they're available at runtime.

Edited to add: see Apple's SDK Compatibility Guide for more info.

OTHER TIPS

You need to weak link the the framework that contain the NSUbiquitousKeyValueStore class. Then in you code do something like things:

if ([NSUbiquitousKeyValueStore class]) {
    // Class wil return non nil uf the class exists.
   NSUbiquitousKeyValueStore *NSUbiquitousKeyValueStore = [NSUbiquitousKeyValueStore new];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top