前言:

1.记录xcode编辑次数很有必要,特别是在频繁发版本时和根据现有编译次数记录估算工期时间很有帮助

2.全部自动化处理,告别手动时代

正文:

1.新建工程或者现有工程里设置:

然后设置xcode-build-bump.sh 和 xcode-version-bump.sh脚本

xcode-build-bump.sh
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# . Select: your Target in Xcode
# . Select: Build Phases Tab
# . Select: Add Build Phase -> Add Run Script
# . Paste code below in to new "Run Script" section
# . Drag the "Run Script" below "Link Binaries With Libraries"
# . Insure that your starting build number is set to a whole integer and not a float (e.g. , not 1.0) buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + ))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${PROJECT_DIR}/${INFOPLIST_FILE}"
xcode-version-bump.sh
# xcode-version-bump.sh
# @desc Auto-increment the version number (only) when a project is archived for export.
# @usage
# . Select: your Target in Xcode
# . Select: Build Phases Tab
# . Select: Add Build Phase -> Add Run Script
# . Paste code below in to new "Run Script" section
# . Check the checkbox "Run script only when installing"
# . Drag the "Run Script" below "Link Binaries With Libraries"
# . Insure your starting version number is in SemVer format (e.g. 1.0.) # This splits a two-decimal version string, such as "0.45.123", allowing us to increment the third position.
VERSIONNUM=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
NEWSUBVERSION=`echo $VERSIONNUM | awk -F "." '{print $3}'`
NEWSUBVERSION=$(($NEWSUBVERSION + ))
NEWVERSIONSTRING=`echo $VERSIONNUM | awk -F "." '{print $1 "." $2 ".'$NEWSUBVERSION'" }'`
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $NEWVERSIONSTRING" "${PROJECT_DIR}/${INFOPLIST_FILE}"

接下来看看编译运行结果:

中途可以任意更改version 和 build,不过只要保持格式一致就可以了。

然后工程里面使用:

#define F(string, args...)                  [NSString stringWithFormat:string, args]

@interface TKViewController ()
@property (weak, nonatomic) IBOutlet UILabel *labelVersion; @end @implementation TKViewController //1.0.0
- (NSString *)bundleShortVersionString{
static NSString *key = @"CFBundleShortVersionString";
return [[NSBundle mainBundle] objectForInfoDictionaryKey:key];
} //
- (NSString *)bundleBuildVersionString{
return [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
} //3.0.0(2938)
- (NSString *)bundleFullVersionString{
NSString *version = [self bundleShortVersionString];
NSString *build = [self bundleBuildVersionString]; return F(@"%@(%@)", version, build);
} - (void)viewDidLoad
{
[super viewDidLoad]; self.labelVersion.text = F(@"version %@",[self bundleFullVersionString]); // Do any additional setup after loading the view, typically from a nib.
}

结果图:

注意:

我的环境是在xcode5.1.1下编译没问题。

Xcode 4.6.3 (4H1503) 会出现:

/Users/tinkl/Library/Developer/Xcode/DerivedData/ZwingIt-glpdhlyoebaqcfdefdfwkgxjapnj/Build/Intermediates/ZwingIt.build/Debug-iphoneos/ZwingIt.build/Script-048F0D0017A7FDD9000E38C5.sh: line : File Doesn't Exist, Will Create: /Users/nebiros/Dropbox/Projects/zwingit-ios-2//Users/nebiros/Dropbox/Projects/zwingit-ios-2/ZwingIt-Info.plist + 1: syntax error: invalid arithmetic operator (error token is "'t Exist, Will Create: /Users/nebiros/Dropbox/Projects/zwingit-ios-//Users/nebiros/Dropbox/Projects/zwingit-ios-2/ZwingIt-Info.plist + 1")

xcode5.0.1没问题

ios Trace xcode buile count的更多相关文章

  1. 【转】 IOS开发xcode报错之has been modified since the precompiled header was built

    本文转载自  IOS开发xcode报错之has been modified since the precompiled header was built 其实我是升级xcode到4.6.3的时候遇到的 ...

  2. IOS开发 xcode报错之has been modified since the precompiled header was built

    转载的文章  很实用 IOS开发xcode报错之has been modified since the precompiled header was built 今天做百度地图的时候第一次发现下面错误 ...

  3. IOS 7 Xcode 5 免IDP证书 真机调试(转载)

    最近转开发了,真的很久没有更新博客了,今天有空写一篇吧. 今天带来的是 IOS 7 Xcode 5 免IDP证书的真机调试.说白了就是穷,不想给苹果交那$99的钱. 注意:虽然可以用这个方法实现真机调 ...

  4. To create my first app in iOS with Xcode(在Xcode创建我的第一个iOS app )

    To create my first app in iOS create the project. In the welcome window, click “Create a new Xcode p ...

  5. iOS开发- Xcode 7添加pch文件

    1.打开你的Xcode工程. 在Supporting Files目录下,选择 File > New > File > iOS > Other > PCH File 然后点 ...

  6. Xcode各版本官方下载, Mac和IOS及Xcode版本历史

    官方下载, 用开发者账户登录,建议用Safari浏览器下载. 官方下载地址: https://developer.apple.com/xcode/downloads/ Xcode 7 7.2 : ht ...

  7. iOS——为Xcode编译POCO C++静态库

    一.POCO C++ library简介 POCO C++ library是一个C++编写的跨平台库,主要实现网络连接.数据库管理以及服务器,适用于跨平台.嵌入式. 二.为Xcode编译POCO C+ ...

  8. ios 8+ (xcode 6.0 +)应用程序Ad Hoc 发布前多设备测试流程详解

    我们开发的程序在经过simulator以及自己的iOS设备测试后,也基本完成应用程序了,这时候我们就可以把它发布出去了更更多的人去测试,我们可以在iOS平台使用ad hoc实现. 你在苹果购买的开发者 ...

  9. Xcode各版本官方下载及百度云盘下载, Mac和IOS及Xcode版本历史.

    官方下载, 用开发者账户登录,建议用Safari浏览器下载. 官方下载地址: https://developer.apple.com/xcode/downloads/ 百度云盘下载地址: http:/ ...

随机推荐

  1. 搭建Discuz! (mysql+apache+Discuz! )

    0. 配置环境 0.0 安装apache 0.1 安装php 1.数据库准备 1.1 创建数据库用户 1.2 创建discuz使用的数据库(编码:utf8-general-ci) 1.3 把1.2创建 ...

  2. ACCESS-关于DELPHI中操作ACCESS数据库中单精度数据的问题

    在近日几个帖子里面,和QQ群的讨论里面,我发现很多网友都遇到的问题都是因为不恰当地使用了单精度/双精度数值.因此想专门就这个话题谈一下. 单精度和双精度数值类型最早出现在C语言中(比较通用的语言里面) ...

  3. KVC, KVO实现原理剖析

    iPhone程序开发 KVO/KVC实现机理分析是本文要介绍的内容,不多说,直接进入话题.我们来看详细内容. Objective-C里面的Key-Value Observing (KVO)机制,非常不 ...

  4. Objective-C Runtime 运行时之五:协议与分类

    Objective-C中的分类允许我们通过给一个类添加方法来扩充它(但是通过category不能添加新的实例变量),并且我们不需要访问类中的代码就可以做到. Objective-C中的协议是普遍存在的 ...

  5. java入门学习(十一)逻辑运算符和位运算符

    请关注我的博客:www.taomaipin.com 家里有急事 暂停了几天,抱歉,现在呢开始说说java的运算语句和运算符 如果想利用java的运算语句 那么就离不开java的运算符,前面第九章讲了j ...

  6. JSON序列化及利用SqlServer系统存储过程sp_send_dbmail发送邮件(一)

    JSON序列化 http://www.cnblogs.com/yubaolee/p/json_serialize.html 利用SqlServer系统存储过程sp_send_dbmail发送邮件(一) ...

  7. hdu 2844 Coins (多重背包)

    题意是给你几个数,再给你这几个数的可以用的个数,然后随机找几个数来累加, 让我算可以累加得到的数的种数! 解题思路:先将背包初始化为-1,再用多重背包计算,最后检索,若bb[i]==i,则说明i这个数 ...

  8. 升级SUSE Linux内核的完整步骤!

    http://blog.sina.com.cn/s/blog_491529d60100061h.html 安装完SLED 10后发现仍然有“热启动网络不通”的问题,原因是内核版本较低,于是升级到2.6 ...

  9. 授予普通域用户远程桌面连接DC/客户端权限

    普通域用户通过远程桌面登录DC: 1)将该用户加入到 Remote Desktop Users 组中

  10. File类的基本操作之读出所有目录路径

    package org.mark.file; import java.io.File; /** * File类的基本操作之读出所有文件夹路径 * 假设给定一个文件夹,要求将此文件夹中的所有文件都列出来 ...