I'm trying to make a Cydia app that will work on iOS 6 and 7, calling some functions from the private framework MusicLibrary. These functions are in different classes in iOS 6 and 7, and the class that exists in iOS 7 doesn't exist in iOS 6. I've got this working in iOS 7, but in iOS 6, I get a "Symbol not found" runtime error at startup. This makes sense, but how do I go about avoiding this? Can I compile one app for both systems?
(I am actually not explicitly linking against the framework, I just included the headers I need.)
Don't link against it and load it dynamically.
static Class aClass;
//...
static void aFunction()
{
id object = [[aClass alloc]init];
//...
}
//...
__attribute__((constructor))
static void Constructor() {
dlopen("/System/Library/PrivateFrameworks/MusicLibrary.framework/MusicLibrary", RTLD_LAZY);
if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_7_0) {
aClass = NSClassFromString(@"ClassNameIniOS7");
} else {
aClass = NSClassFromString(@"ClassNameIniOS6");
}
//...
}