How to sync localized storyboards' strings after modifying storyboard in Xcode 5 - ios7

I'm just starting to look at IOS Apps' localization in XCode 5 and I've tried to add an Italian Localization:
Xcode 5 automatically generates the Main.strings file with a single entry, for the only label I've put within the Main.storyboard file:
/* Class = "IBUILabel"; text = "Label"; ObjectID = "PeT-4z-NSf"; */
"PeT-4z-NSf.text" = "Etichetta";
If I later modify the Main.storyboard file adding a new button to the view, then how should I tell Xcode 5, if possible, to add missing localization strings to the Main.strings file? Should I add a new entry by hand by looking at the Object ID field in Interface Builder (it works, but I don't know if this is how it is meant to update storyboards' localization)? Can I run something like genstrings on the Main.storyboard file to extract all the labels' text and add the new ones to the localized Main.strings files?

Check out ReMafoX, it's a Mac app that perfectly solves your problem. It can be easily installed and integrated within your project, watch this video for a detailed walkthrough.
Alternatively, if you prefer an open-source CLI tool without a GUI, you can also use BartyCrouch.
Install BartyCrouch via Homebrew:
brew install bartycrouch
Alternatively, install it via Mint:
mint install Flinesoft/BartyCrouch
Incrementally update your Storyboards/XIBs Strings files:
$ bartycrouch update
This will do exactly what you were looking for.
In order to keep your Storyboards/XIBs Strings files updated over time I highly recommend adding a build script (instructions on how to add a build script here):
if which bartycrouch > /dev/null; then
bartycrouch update -x
bartycrouch lint -x
else
echo "warning: BartyCrouch not installed, download it from https://github.com/Flinesoft/BartyCrouch"
fi
In addition to incrementally updating your Storyboards/XIBs Strings files this will also make sure your Localizable.strings files stay updated with newly added keys in code using NSLocalizedString and show warnings for duplicate keys or empty values.
Make sure to checkout BartyCrouch on GitHub for additional information.

The file that Xcode does not update automatically (at least 5.x version didn't) is the app's Localizable Strings. You can build a fresh file from Main.storyboard as follows:
In the project Navigator (the leftmost pane) click on the Main.storyboard file. In the Utilities pane (the rightmost pane) click on Show the File inspector icon. It is the leftmost icon in blue in the image below:
.
On the right pane that will appear, one of the sections will be Localization:
Uncheck the English (Localizable Strings) row and in the window that will pop-up check the Delete localized resource files from disk and click the Remove button (you do not have to check delete, in which case Xcode will ask for a permission to override it when you build it next).
Then check English (Localizable Strings) again to build it from scratch.

Using Xcode 6 the following worked for me:
I changed the localization for a language from "Localizable Strings" to "Interface Builder ..." like suggested at the SO question posted by h.orim. However the setting did not change, it still was set to "Localizable Strings". The next step now is to do that again, so Xcode will find the Storyboard it just created and show a prompt asking if it should be used or replaced. Now click on "Use file" instead of "Replace", otherwise the same will happen again.
Now you should have a localized Storyboard in the desired language. After you now switch back to "Localizable Strings" you will have a file containing all current strings used in the storyboard with your previous translations still in place.

Another way is to do it manually by selecting on the storyboard the field to translate. Go to the "Identity Inspector" and copy the Object ID (something like HP8-op-SmX).
After that, open the storyboard langage file (Main.strings, most cases) and past the Object ID. Depending your needs, you just have to add .text or .placeholder.
"HP8-op-SmX.placeholder" = "My translated placeholder text";
"HP9-op-VvD.text" = "My translated text";
Save, clean & build. It's a little bit painful but can save a lot of time if you only need to translate few things.

You can use a script called UpdatStoryboardStrings for this!Get it here: https://github.com/AppliedIS/iOSL10n
Intructions for use: http://blog.appliedis.com/2013/05/22/localization-of-an-xcode-ios-app-part-2/

With Xcode 6+, ideally developers should not have to manually manage strings files. Use XLIFF export to automatically gather development language strings to send to translators, and then use XLIFF import to update the strings files with translations.
https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/LocalizingYourApp/LocalizingYourApp.html#//apple_ref/doc/uid/10000171i-CH5-SW9
Another option is to use ibtool --export-strings-file directly.
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/ibtool.1.html

There are two options:
Option 1
Xcode can "reload" the file by converting the file to either an [Interface Builder Cocoa Touch Storyboard] file type or a [Localizable Strings] file type.
Select your base storyboard file from the Project Navigator
Find the Localization section in the File Inspector
If your file is currently a [Localizable Strings], change it to [Interface Builder Cocoa Touch Storyboard] or vice-versa.
Xcode should have converted your storyboard to the current version, while preserving your old localization efforts. Here you can change the file back to the original file type if you would like.
Option 2
Use ibtool to extract the strings in your storyboard.
Open the Terminal application
Locate your Base.lproj directory
Use this line to extract the strings:
ibtool MainStoryboard.storyboard --generate-strings-file file_name.strings
After ibtool extracts the strings to file_name.strings, you can copy and paste it to your original .strings file

Tested with Xcode 11, you can simply deselect the language.
Do not delete the file on disk.
And then choose to use the existing file.
The old translations will be kept and the new keys will be added.

Related

How to use ctags for code documentation

I have some source code that I want to document without touching the code. For every source file (e.g., example.cpp, example.f90, etc.) I would like to have a separate documentation file (e.g., example.cpp.doc, example.f90.doc) that has some metadata (ctag) linking it to the original source file.
Ideally I could open the source file and the documentation file in parallel views in my favorite editor (ViM) and have the two files synced so that they scroll together. In this manner, I can keep my documentation visually inline with the un-touched source code.
I know this is likely to be a unique scenario. But I'm hoping someone else has already figured this out.
Is this even a possibility?
Create the initial .doc structure outside of Vim such that the "metadata" you want to keep is in the same line number as the original file.
Then open the two files in different Vim windows with vim -O example.cpp example.cpp.doc. At this point use :windo set scrollbind to enable scroll binding, which will allow to navigate any of the windows while keeping both in sync.

Icon specified in info.plist not found under the top level app wrapper

I'm trying to upload my binary to iTunes Connect using Applicaton Loader. When I select the file and hit send, it sends for about a second and then this error pops up,
Icon specified in the info.plist not found under the top level app wrapper: Default -Landscape#2x~ipad.png
What does this mean? How do I fix it?
Another setting that can cause the issue:
You have to make sure the icon files are also found under build phases/bundle resources
Edit your projects .plist file "as source code" i.e. open it in any old text editor. Then manually edit the icon file names until they make sense.
The .plist is case-sensitive when validated and archived for upload to the App Store.
If you have this in the .plist:
icon-72#2X.png
the file name can not be
icon-72#2x.png
owing to the the case change of the x character .
I rename the file and corresponding change the name of icon file in the info.plist and this solution works for me.
Clean your build
Make sure the file is actually on the file system
Make sure you can see the file in the project navigator.
Most likely step 3 will fail. If so, drag the icon from the finder onto the Project Navigator. When asked, uncheck the "copy ..blabla" option because since the file is already there where you are dragging it to, it would fail. Once the file shows up in the Project Navigator you should be golden.
Also check that you dont have 2 icons with the same name anywhere in your project folders.
I am thinking that the answer to this question will vary in time because Apple constantly changes the application validation rules. These validation rules will surface only when you are submitting your app to the AppStore.
In this particular situation, the validation error happened to me while uploading the app on 08/03/2012.
The solution was fairly straight forward. I had to move to icon files which I had located in a folder nested within the project directory all to way up to the TOP LEVEL project directory - one that has the project file in it. Once I did that and readded the files back to the Resources in my project the validation error went away.
Of course you should check that this issue is not caused by misspelled filenames i.e. differences between your plist file and true names of icon files on your file system.
Another little issue that caught me out was an empty string. I got the cryptic failure message ...
Icon specified in the info.plist not found under the top level app wrapper:
And found this lurking in my plist
<string></string>
I was similar problem's. I have resolve to do this
1/ delete your application Icone in your Target
2/ rename your icone ex: applicationNameSmall.png
3/ add your icone in your application.
This, works for me.
Error is coming up because the App Store is checking names of icon files based upon yourProject-info.plist. If they don't match, error message.
To resolve this issue: Go to yourProject-info.plist in xcode and check BOTH "icon-files" and "icon-files(IOS5)" arrays. You'll want to make sure that each string corresponds with the icon files you have in the file directory.
Change or delete mismatched string names (I had to delete a blank string). Rebuild. As other posters have noted, names are case-sensitive, so be mindful of that too.
Sometimes Icon.png files needs to be open in some image editing tool (e.g Adob Photoshop) and save as a new image. This works fine. Check attached images some times image properties don't change by renaming image file manually.
I had the same issue. I just added the image files it complained about to the project in the viewer. Not sure if that was the right thing to do, but it resolved the issue for me.
I had a silly mistake, in my info.plist the i had Icon.png, and the real file name was icon.png (no uppercase)
Fix the images issues it suggests.
Clean your project.
Build and run to make sure nothing has broken.
Delete the previous archive
Make a new archive (Product -> Archive)
This worked for me. I had to rearchive my application cause the previous one was not updated.
I had the same problem. I gone to Targets->Build Phases and deleted from there old (test) icons which I had pushed early. Good luck:)

Cannot create localizable strings files copies in XCode4

I have a "Resources/en.lproj/Localized.strings" file, with some key/value pairs in the format:
"key"="value";
I select this file and in File Inspector in the Utilities Pane I choose to add a new localization (es) pressing the '+' button in the Localization tab.
This action should create a new file "Resources/es.lproj/Localized.strings", but instead the original "Resources/en.lproj/Localized.strings" now displays a small triangle at the left ( as if it were a folder ) and holds inside two files Localized.strings (English) and Localized.strings (Spanish). No es.lproj directory created.
I have never read of this behavior even in references to this using XCode4.
What I'm missing?
Updated info:
I have checked the app bundle installed in my iPhone Simulator and the folders are created there, with the corresponding files.
I don't know if this is the default way but is confusing to me since reading the documentation this is not what I understand.
Your could try this : Quit XCode, relaunch your project. Remove all localizations from your project properties (keeping the files when asked), add them back, remove es localization on your file, then add it back.

How to stop huge Prefix.pch.gch file from being copied into application bundle

For some reason, XCode has decided to start copying a huge Prefix.pch.gch file into my application's resources folder when building. This file is not in the Copy Bundle Resources build phase, nor can I find any other project setting that should tell XCode to do this. Has anyone seen this before and know what's going on?
I had a problem with the same symptoms today, it turned out that it was due to one of my objective C files being included in the Copy Bundle Resources files phase of the target (either due to a drag and drop accident, or the xcodeproj file getting corrupted at some point). GCC was then helpfully including the precompiled headers for the prefix header in the target as there is a dependency from the source file.
Doing a Get Info on the source file in question didn't show all the tabs on the file info dialog, even though the file type was set to sourcecode.c.objc.
Removing the file from the project and re-adding it cured the problem.
You could try doing "Show Package Contents" on your xcode project file in the finder, then opening the project.pbxproj file in a text editor (not xcode).
If you search for ".pch" and/or ".gch", you might spot something.
Are there any Copy Files phases?
Is the Prefix.pch.gch file in your project's group tree? The easiest way to check this would be to select the project object, then search for “gch” in the Detail view.
I solved this problem in a different way. Firstly I like to make use of the prefix file so I have lots of includes for standard logging, colours etc.
For every include to the prefix file ensure that each include is only processed once! This can be done by putting:
#ifndef __<Classname>__
#define __<Classname>__
< your original header file here >
#endif
If you select the "Project" item of the "Project menu and then the "Detail" tab view and then select the project in the "Groups & Files" list on the left is the files listed on the right view have a checkbox? and is that checkbox checked? if so then un-check it.

Are Objective-C function names stored in text?

I don't remember where I heard about it, (I think I was searching up on how selectors worked and it ended up not being exactly the same as a callback function) and I can't confirm it. But more importantly than that, is there a way I could get a list of the function names from another application?
See class-dump.
You can sometimes see a list of the method names in an application. Find the .ipa file for the app (possibly in the Music->iTunes->Mobile Applications directory on a Mac). Make a copy of one of the ipa files and change it from .ipa to .zip. Unzip the file and in the Payload folder, there's a file with the same name as the app. Right click on it and "Show Package Contents". In there, you'll find another file with the same name as the app (with no extension). This is the executable file for the app. If you open it in a text editor like BBEdit, you'll sometimes be able to see some method names, as well as a list of the frameworks the app is built against. You can find the path name where things were kept too, often with the developer's name.
For example, looking into the Japanese dicitonary Daijirin, I can see these methods:
-[HMWebSupport openMONOKAKIDOSupportWithSafariForView:style:]
-[HistoryViewController viewWillAppear:]
I can also see that one of the developers was called Norihito, and he was using SVN: /Users/norihito/Developer/SVN/Mobile/DAIJIRIN/Other
Other applications (like Weightbot) don't show as much information. I don't know the reason it shows up some times and doesn't other times.