I'm trying to use some library built in XCode 5 to link in some app in XCode 4. That library has references to constants defined in iOS7 SDK, but not in iOS6 SDK.

So I'm getting this error:

Undefined symbols for architecture armv7s: "_CBPeripheralManagerRestoredStateServicesKey", referenced from:

Is there any way to preserve backward compatibility with XCode 4 and SDK for iOS6?

有帮助吗?

解决方案

+ (NSString *)getCoreBluetoothConstantByName:(NSString *)name
    {
    void *libHandle = dlopen("/System/Library/Frameworks/CoreBluetooth.framework/CoreBluetooth", RTLD_LOCAL);

if (libHandle != NULL)
    {
    NSString **key = dlsym(libHandle, [name cStringUsingEncoding:NSASCIIStringEncoding]);

    dlclose(libHandle);

    return [[*key copy] autorelease];
    }

return nil;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top