简体   繁体   English

在iPhone的xcode中设置捆绑包

[英]Settings Bundle in xcode for iphone

I'm trying to set my build version and build date in my app in settings bundle following this tutorial . 我正在尝试按照本教程在设置包中的应用程序中设置构建版本和构建日期。

But I keep getting this error no matter what: 但无论如何我都会收到这个错误:

line 9: File Doesn't Exist, Will Create: /Volumes/Work Invalid Arguments + 1: syntax error: invalid arithmetic operator (error token is "'t Exist, Will Create: /Volumes/Work Invalid Arguments + 1") Command /bin/sh failed with exit code 1 第9行:文件不存在,将创建:/ Volumes /工作无效参数+ 1:语法错误:无效算术运算符(错误标记为“不存在,将创建:/卷/工作无效参数+ 1”)命令/ bin / sh失败,退出代码为1

Could somebody please help me.... 有人可以帮帮我....

Thanks in advance. 提前致谢。

Ok , I found the mistake : when we post, revers quotes are use to formate the message. 好吧,我发现了错误:当我们发布时,反向引号用于合成消息。 So, please replace all by a reverse quote ` 所以,请通过反向引用'替换所有

echo "#define BUILD_DATE @\\"date "+%d/%m/%Y %H:%M"\\"" > build.h echo“#define BUILD_DATE @ \\”date“+%d /%m /%Y%H:%M”\\“”> build.h

build, and check your build.h 构建,并检查您的build.h

My solution is to create a build.h header with the build date (build version is related to build date), and use this from my app to display the App version + build date. 我的解决方案是使用构建日期创建一个build.h头文件(构建版本与构建日期相关),并从我的应用程序中使用它来显示App版本+构建日期。

Of course, build.h need to be refresh each time you build your App. 当然,每次构建应用程序时都需要刷新build.h。

So, here is how I do this : 那么,我是这样做的:

Select your Targets (where you can set Bundle ID ...) / Build Phases. 选择您的目标(您可以在其中设置分发包ID ...)/构建阶段。 Go to menu Editor/Add Build Phase/Add Run Script Build Phase. 转到菜单编辑器/添加构建阶段/添加运行脚本构建阶段。 Move the new created line (Run Script) up to the line "Compile sources" (use drag&drop). 将新创建的行(Run Script)向上移动到“Compile sources”行(使用拖放操作)。 open the line "Run script", and replace Type a script... with : 打开“运行脚本”行,并替换Type a script ... with:

echo "#define BUILD_DATE @\\" date "+%d/%m/%Y %H:%M" \\"" > build.h echo“#define BUILD_DATE @ \\” date "+%d/%m/%Y %H:%M" \\“”> build.h

Now each time you will build, build.h will be re-create. 现在每次构建时,都会重新创建build.h。

So, now you need to build => you will have your 1st build.h avail at root of your project. 所以,现在你需要构建=>你将在你的项目的根目录下获得你的第一个build.h。 Add it to your project. 将其添加到您的项目中。

Now, import build.h in the VC where you need the information. 现在,在需要信息的VC中导入build.h。

Here is how I use it (I have a iboultet to a label) 这是我如何使用它(我有一个标签的iboultet)

- (void)viewDidLoad
{
    [super viewDidLoad];

    //cf http://stackoverflow.com/questions/3015796/how-to-programmatically-display-version-of-target-in-iphone-app-xcode
    NSString * appVersionString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];

    self.version.text = [NSString stringWithFormat:@"v %@  %@", appVersionString,BUILD_DATE];

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM