这可能不仅限于 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.
我发现 Xcode 6 支持 Apple 新的 Cocoa Touch 框架,为这个问题提供了一个简单的答案.在为您创建的默认头文件中,例如 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 通用框架的版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!