0

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

Could somebody please help me....

Thanks in advance.

Unheilig
  • 16,196
  • 193
  • 68
  • 98
Anish688
  • 81
  • 11

2 Answers2

2

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

build, and check your build.h

Armand DOHM
  • 1,121
  • 1
  • 7
  • 9
0

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.

Of course, build.h need to be refresh each time you build your App.

So, here is how I do this :

Select your Targets (where you can set Bundle ID ...) / Build Phases. 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). open the line "Run script", and replace Type a script... with :

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

Now each time you will build, build.h will be re-create.

So, now you need to build => you will have your 1st build.h avail at root of your project. Add it to your project.

Now, import build.h in the VC where you need the information.

Here is how I use it (I have a iboultet to a label)

- (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];

}
Armand DOHM
  • 1,121
  • 1
  • 7
  • 9
  • Hello Sir i did as per you suggested but it showed me error at BUILD_DATE, so i created a new label and wrote NSString * appBuildString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]; self.build.text = [NSString stringWithFormat:@"Build %@ ", appBuildString]; but the problem is the values never increments both the values also is buildstring and version string supposed to be same thing? but what i wanted to show was build date and time in the build section. – Anish688 Mar 08 '14 at 17:15
  • CFBundleVersion is your app version. the value of App version is not auto-incremented, you have to change it by hand in your App Target / tab General (just under boundless identifier). Did you import "build.h" in your viewController ? can you show me the error you receive + confirm your build.h is something like `#define BUILD_DATE @"05/03/2014 09:04"` – Armand DOHM Mar 08 '14 at 17:32
  • In debug area it shows me Build Date :(null) And in build.h #define BUILD_DATE @"date +%d/%m/%Y %H:%M" – Anish688 Mar 08 '14 at 17:47