在客户端获取iOS通用框架的版本号 [英] Get version number of iOS Universal Framework in client
问题描述
这可能不限于 iOS通用框架,而是所有xxx.framework文件。然而,我似乎找不到如何获取当前版本和在客户端应用程序中构建框架的文档。在一个应用程序中,你会使用类似:
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"];
这将给你存储在Info.plist中的应用程序的当前信息。但是我们如何找到一个框架的信息。
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.
推荐答案
我发现苹果新推出的Cocoa Touch框架支持Xcode 6,一个容易回答这个问题。在为您创建的默认头文件中,像 Framework.h
,您将看到为您声明的两个常量。这些定义后来可能在运行时由内部框架逻辑。但我已经确认他们是从框架的plist。
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[];
这篇关于在客户端获取iOS通用框架的版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!