Bundle versions string, short 和 Bundle version的区别

  1. NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];  
  2.  CFShow(infoDictionary);  
  3. // app名称  
  4.  NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];  
  5.  // app版本  
  6.  NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];  
  7.  // app build版本  
  8.  NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"];  
  9.   
  10.   
  11.       
  12.     //手机序列号  
  13.     NSString* identifierNumber = [[UIDevice currentDevice] uniqueIdentifier];  
  14.     NSLog(@"手机序列号: %@",identifierNumber);  
  15.     //手机别名: 用户定义的名称  
  16.     NSString* userPhoneName = [[UIDevice currentDevice] name];  
  17.     NSLog(@"手机别名: %@", userPhoneName);  
  18.     //设备名称  
  19.     NSString* deviceName = [[UIDevice currentDevice] systemName];  
  20.     NSLog(@"设备名称: %@",deviceName );  
  21.     //手机系统版本  
  22.     NSString* phoneVersion = [[UIDevice currentDevice] systemVersion];  
  23.     NSLog(@"手机系统版本: %@", phoneVersion);  
  24.     //手机型号  
  25.     NSString* phoneModel = [[UIDevice currentDevice] model];  
  26.     NSLog(@"手机型号: %@",phoneModel );  
  27.     //地方型号  (国际化区域名称)  
  28.     NSString* localPhoneModel = [[UIDevice currentDevice] localizedModel];  
  29.     NSLog(@"国际化区域名称: %@",localPhoneModel );  
  30.       
  31.     NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];  
  32.     // 当前应用名称  
  33.     NSString *appCurName = [infoDictionary objectForKey:@"CFBundleDisplayName"];  
  34.     NSLog(@"当前应用名称:%@",appCurName);  
  35.     // 当前应用软件版本  比如:1.0.1  
  36.     NSString *appCurVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];  
  37.     NSLog(@"当前应用软件版本:%@",appCurVersion);  
  38.     // 当前应用版本号码   int类型  
  39.     NSString *appCurVersionNum = [infoDictionary objectForKey:@"CFBundleVersion"];  
  40.     NSLog(@"当前应用版本号码:%@",appCurVersionNum);  

http://7090.iteye.com/blog/1775883

我们建立一个工程后,会在Supporting files下面看到一个"工程名-Info.plist"的文件,这个是对工程做一些运行期配置的文件,很重要,不能删除。

如果你在网上下载的工程中的这个文件名只是Info.plist,那么恭喜你,这个工程太老了,是用包含SDK2.0以前的Xcode生成的,不过没关系,不影响使用。

如果你使用文本编辑器打开这个文件,你会发现这是一个XML格式的文本文件,一般我们不用文本编辑器直接编辑这个文件,而是通过Xcode编辑。

下面是这个文件的一个例子:

下面是对这里可能出现的字段的解释:

Localiztion native development region --- CFBundleDevelopmentRegion 本地化相关,如果用户所在地没有相应的语言资源,则用这个key的value来作为默认.

Bundle display name --- CFBundleDisplayName 设置程序安装后显示的名称。应用程序名称限制在10-12个字符,如果超出,将被显示缩写名称。

Executaule file -- CFBundleExecutable 程序安装包的名称

Icon file --- CFBundleIconFile 应用程序图标名称,一般为icon.png

Bundle identifier --- CFBundleIdentifier 该束的唯一标识字符串,该字符串的格式类似com.yourcompany.yourapp,如果使用模拟器跑你的应用,这个字段没有用处,如果你需要把你的应用部署到设备上,你必须生成一个证书,而在生成证书的时候,在apple的网站上需要增加相应的app IDs.这里有一个字段Bundle identifier,如果这个Bundle identifier是一个完整字符串,那么文件中的这个字段必须和后者完全相同,如果app IDs中的字段含有通配符*,那么文件中的字符串必须符合后者的描述。

InfoDictionary version --- CFBundleInfoDictionaryVersion  Info.plist格式的版本信息

Bundle OS Type code -- CFBundlePackageType:用来标识束类型的四个字母长的代码,(网上找的,不解??)

Bundle versions string, short --- CFBundleShortVersionString 面向用户市场的束的版本字符串,(网上找的,不解??)

Bundle creator OS Type code --- CFBundleSignature:用来标识创建者的四个字母长的代码,(网上找的,不解??)

Bundle version --- CFBundleVersion 应用程序版本号,每次部署应用程序的一个新版本时,将会增加这个编号,在app store上用的。

Application require iPhone environment -- LSRequiresIPhoneOS:用于指示程序包是否只能运行在iPhone OS 系统上。Xcode自动加入这个键,并将它的值设置为true。您不应该改变这个键的值。

Main nib file base name -- NSMainNibFile 这是一个字符串,指定应用程序主nib文件的名称。如果您希望使用其它的nib文件(而不是Xcode为工程创建的缺省文件)作为主nib文件,可以将该nib文件名关联到这个键上。nib文件名不应该包含.nib扩展名。这个字段可以删除,你可以参考我前面的文章,main函数研究。

supported interface orientations -- UISupportedInterfaceOrientations 程序默认支持的方向。
 

 

下面是转载的。

Application uses Wi-Fi
如果应用程序需要wi-fi才能工作,应该将此属性设置为true。这么做会提示用户,如果没有打开wi-fi的话,打开wi-fi。为了节省电力,iphone会在30分钟后自动关闭应用程序中的任何wi-fi。设置这一个属性可以防止这种情况的发生,并且保持连接处于活动状态


Bundle version is the internal version number of your app. 

Short version string is the publically visible version of your app. 

So for example, if you iterate your version number every time you do an internal build for your beta testers (or whatever), your bundle version might be 2.0.0.12345b7, but you don't want the public to see that, so you set your short version string to 2.0. 

Short version string seems to be optional, so if you leave it blank then the bundle version is what people will see (i.e. that's what will be displayed on the App Store). 

Your short version string can't have more than 3 parts, e.g. 2.0.1 is okay, but 2.0.0.1 isn't. If you don't have a short version string, then the same rules apply to your bundle ID (basically the public app version has this restriction and the private app version doesn't). 



iTunes Connect 
This is the version number shown in the App Store; This must be a pure version number like1.2.3 

Bundle Version (CFBundleVersion) 
This doesn't need to be a pure version number. This can be something like 12345 or 1.2.3 (Build 12345AB). This is shown in the About window for Mac OS X apps for example and is often more a "Build Number" than a "Version Number". 

Bundle Version String (CFBundleShortVersionString) This value is used as the "real" version number. This must be the same string as used for the version in iTunes Connect. 

大体意思就是Bundle Version String是正式的,跟itunes上的版本号一致,Bundle Version 可用作内部版本时使用,当Bundle Version String缺省时,Bundle Version替代Bundle Version String的功能,同时也继承他的限制(比如格式,位数等),需与itunes上的版本号保持一致。。http://7090.iteye.com/blog/1775883

NSString *executableFile = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleExecutableKey];


    NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleVersionKey];

 

还有其它很多信息可由infoDictionary获得,以下是官方文档里的说明:

information Property List Keys
Standard keys found in a bundle’s information property list file.

const CFStringRef kCFBundleInfoDictionaryVersionKey;
const CFStringRef kCFBundleExecutableKey;
const CFStringRef kCFBundleIdentifierKey;
const CFStringRef kCFBundleVersionKey;
const CFStringRef kCFBundleDevelopmentRegionKey;
const CFStringRef kCFBundleNameKey;
const CFStringRef kCFBundleLocalizationsKey;


Constants
kCFBundleInfoDictionaryVersionKey
The version of the information property list format.
Available in iOS 2.0 and later.
Declared in CFBundle.h.
kCFBundleExecutableKey
The name of the executable in this bundle (if any).
Available in iOS 2.0 and later.
Declared in CFBundle.h.
kCFBundleIdentifierKey
The bundle identifier.
Available in iOS 2.0 and later.
Declared in CFBundle.h.
kCFBundleVersionKey
The version number of the bundle.
For Mac OS 9 style version numbers (for example “2.5.3d5”), clients can use CFBundleGetVersionNumber instead of accessing this key directly since that function will properly convert the version string into its compact integer representation.
Available in iOS 2.0 and later.
Declared in CFBundle.h.
kCFBundleDevelopmentRegionKey
The name of the development language of the bundle.
When CFBundle looks for resources, the fallback is to look in the lproj whose name is given by the kCFBundleDevelopmentRegionKey in the Info.plist file. You must, therefore, ensure that a bundle contains an lproj with that exact name containing a copy of every localized resource, otherwise CFBundle cannot guarantee the fallback mechanism will work.
Available in iOS 2.0 and later.
Declared in CFBundle.h.
kCFBundleNameKey
The human-readable name of the bundle.
This key is often found in the InfoPlist.strings since it is usually localized.
Available in iOS 2.0 and later.
Declared in CFBundle.h.
kCFBundleLocalizationsKey
Allows an unbundled application that handles localization itself to specify which localizations it has available.
Available in iOS 2.0 and later.
Declared in CFBundle.h.
Declared In
CFBundle.h

http://danal.blog.51cto.com/3353275/655317

如何设置App的版本号


其实真正正确的设置应该是正如上面所举的Apple Store例子,CFBundleShortVersionString是三个通过(.)点分隔的正整数或0,例如2.9.1;CFBundleVersion是一个整数,例如120269。

这里用的是应该,也就是说你也可以不按照这样来设置。
比如苹果官方的建议是CFBundleVersion也应该是2.9.1这种格式;
又比如我曾经上架的一个App,五子牛棋,因为当时没有注意这些细节,所以都设置为1.0了,这样也是没有问题的;
还有就是如果你用Flurry的话,最好把CFBundleVersion设置成CFBundleShortVersionString.XXXX,例如前面的截图中的1.0.0.32369,最后一个数字一般是版本管理工具的最后一条Changelist号。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值