Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get version number of iOS Universal Framework in client

Tags:

This is likely not limited to iOS Universal Frameworks but all xxx.framework files. However I can't seem to find documentation on how to get the current version and build of a framework within the client application. Within an app you'd use something like:

    NSString *name = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];     NSString *build = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];     NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; 

That would give you the current information stored in the Info.plist for the app. But how to we find that information for a framework. And in my case, specifically an embedded framework.

like image 792
Ryan Poolos Avatar asked Jul 02 '14 18:07

Ryan Poolos


People also ask

How do I find my Xcode framework version?

For xcode version click xcode>about xcode. For the framework just open a header file from that framework, usually in the comments on top the version is mentioned.

What framework does iOS use?

The UIKit framework provides the required infrastructure for your iOS or tvOS apps.


2 Answers

Here's a solution that does work with Universal Frameworks. Just replace SomeFrameworkClass with a class from the desired framework.

if let sdkVersion = Bundle(for: SomeFrameworkClass.self).infoDictionary?["CFBundleShortVersionString"] {     // sdkVersion is available here } 
like image 103
picciano Avatar answered Oct 03 '22 09:10

picciano


I have found that Apple's new Cocoa Touch frameworks supported in Xcode 6, offer an easy answer to this problem. In the default header file created for you, something like Framework.h, you'll see two constants declared for you. These are defined later presumably at runtime by internal framework logic. But I have confirmed they're pulled from the plist for the framework.

//! Project version number for LocalSearch. FOUNDATION_EXPORT double FrameworkVersionNumber;  //! Project version string for LocalSearch. FOUNDATION_EXPORT const unsigned char FrameworkVersionString[]; 
like image 22
Ryan Poolos Avatar answered Oct 03 '22 08:10

Ryan Poolos