In objective C how to determine a library framework version

Posted on 2012-09-12
Last Modified: 2016-02-10
Is there any method in objective c or NS libraries to retrieve the version number of a framework library?
I want to do it from the code because I have a framework library and some apps that depend on this library.  I usually distribute the framework once but need to update the apps continuously; however, when someone has an issue with an app, I would like to make sure they are using the latest framework library so I want to update my program to display the framework version.
I know that one way would be to add a method to the framework but it's already distributed.
Another way would be to look in their /Library/Frameworks/myframework but I would prefer to use an existing method to get the framework version if possible.
Question by:rudy2024
    LVL 33

    Accepted Solution

    Probably, you link a project with your framework statically, so you can add a macro to your framework like:
    (If I understand your question correctly).

    In Objective-C you can use respondToSelector method to detect if a method exists in a class and this way is used sometimes to detect programmatically the UIKit version.
    For example, only in iOS 5 you can use the appearance feature:
    if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) {
        [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"oho.png"] forBarMetrics:UIBarMetricsDefault];

    You probably know that you can detect the bundle version:
    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];

    You can detect the iOS version:
    if ([[[UIDevice currentDevice] systemVersion] floatValue] > 5.0) {
    More here:
    Build Programming Guide
    Maybe this way with the bundles will help you.

    It is possible ot use a macro:

        NSLog(@"iPhone 4.2");

    or __IPHONE_OS_VERSION_MIN_REQUIRED, All of these defines are here:

    Read this post about it:
    Tips & Tricks for conditional iOS3, iOS3.2 and iOS4 code

    Author Closing Comment

    Thank you for your answer, the links were also very helpful, now I know what to do next time I release a framework update.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    The error "There was an error performing the update" occurred on a Mac OS X client workstation running  Symantec AntiVirus for Mac ( - the Enterprise product vers…
    In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now