2

我试图通过使用 kCFBundleNameKey 来获取包的短名称

NSString *shortBundleName=[[NSBundle mainBundle] 
        objectForInfoDictionaryKey:(NSString *) kCFBundleNameKey];

它工作正常但是当我有多个目标由于某种原因它返回 null 时,是否有解决方法?

获取捆绑包工作正常:

NSString *fullBundleName=[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *) kCFBundleIdentifierKey];

4

1 回答 1

0

核心基础/CFBundle.h:

CF_EXPORT
const CFStringRef kCFBundleNameKey;
/* The human-readable name of the bundle.  
This key is often found in the InfoPlist.strings 
since it is usually localized. */

所以,你应该注意你的目标 info.plist

于 2016-02-18T09:10:57.230 回答