views:

210

answers:

2

Hello,

I know there's a way to preprocess my info.plist file, but is there a similar way to process strings files inside my Settings.bundle?

My problem: I have an iPhone app and I want the the user to know about the currently installed version. I do this by displaying it in the apps settings. Now every time i change the bundle version in my info.plist i also have to change the version in the Root.strings in the Settings.bundle. I could run a script action that updates it, but it would be nice to use the preprocessor since I could do even more fun things with it.

Thanks!

A: 

Make it so that your view asks the bundle and then directly queries the Info.plist file and extracts the CFBundleVersion (or the appropriate key you wish to extract) The version should never need to be stored in a .strings file. Next all you need to do is have a format string to prepare it for display. One useful thing if you care about localization is to instead have a localized string in your .strings labeled something like "%@<CFBundleVersion format string>" = "Version: %@"; Then you get a quick visual indicator if your localizers have done their jobs in all languages.

MyInfoView *infoView = /*...*/;
NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
infoView.versionLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%@<CFBundleVersion format string>",nil), version];
fbartho
If the string is going to be present in the Settings.app then the version needs to be in a strings file. Please reread my question.
stigi
+1  A: 

The preprocessor XCode runs on all string-files is copystrings. It resides in /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources. It's a simple ruby script, but it dosen't support any preprocessing/macro-expansion.

You could of cause extend the script, but then you would be easier off with a different script running in a run script build phase, as you already suggested.

tonklon
thanks. didn't know about copystrings. +1 for that
stigi