Preprocessor String File During Xcode Build

I know there is a way to project my info.plist file, but is there a similar way to handle string files inside my Settings.bundle?

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

Thanks!

+4
source share
2 answers

The Xcode preprocessor works on all string files - this is copying. It is located in / Developer / Library / Xcode / Plug -ins / CoreBuildTasks.xcplugin / Contents / Resources. This is a simple ruby ​​script, but it does not support any preprocessing / macro expansion.

You can call the script extension, but then it will be easier for you to run another script at the script build stage, as you already said.

+3
source

CFBundleVersion your view request a package and then directly request the Info.plist file and retrieve the CFBundleVersion (or the corresponding key that you want to extract). The version should not be stored in the .strings file. Then all you have to do is have a format string to prepare it for display. One useful thing if you care about localization is that instead of your localized string in your .strings something like "%@<CFBundleVersion format string>" = "Version: %@"; . Then you get a quick visual indicator if your localizers completed their tasks in all languages.

 MyInfoView *infoView = /*...*/; NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]; infoView.versionLabel.text = [NSString stringWithFormat:NSLocalizedString(@"%@<CFBundleVersion format string>",nil), version]; 
-1
source

Source: https://habr.com/ru/post/1309772/


All Articles