Menu Home

iOS:How to get your framework version using code

Add these lines in your Framework header file.
eg. PrefixFramework.h

//! Project version number for LocalSearch.
FOUNDATION_EXPORT double PrefixFrameworkVersionNumber;

//! Project version string for LocalSearch.
FOUNDATION_EXPORT const unsigned char PrefixFrameworkVersionString[];

There arguments will be filled by iOS framework logic.And you can get the version like this:

+(NSString*) playerVersion {
    NSRange range_, rangeslash;
    NSString *version = [[NSString alloc]initWithUTF8String:(const char*)PrefixFrameworkVersionString];
    range_ = [version rangeOfString:@"-"];
    rangeslash = [version rangeOfString:@"\n"];
    if (range_.location != NSNotFound) {
        NSRange rangleVersion;
        rangleVersion.location = range_.location + 1;
        rangleVersion.length = rangeslash.location - range_.location - 1;
        return [version substringWithRange:rangleVersion];
        return @"Unknown";

Categories: iOS

Tagged as:


Leave a Reply

Your email address will not be published.