How to change all localized Storyboard files at once? - iphone

I have a localized storyboard file the old way (no use of "Base Internationalization"):
I changed the first file by adding a new ViewController. Now I realized, that these changes don't effect the other (localized) storyboard files.
How can I edit all the storyboard files at once?

You don't. You have to change each file individually. That's why Apple created "Base Internationalization."
I used to deal with an OS X app with 23 translations and many nib files. Here's how the process looked prior to Base Internationalization:
Work only in one language
At some point close to release, localize
Hope desperately that you will not need to touch localized resources until release
Release
Blow away your localized resource files and begin another round
It's not pretty. Again, that's why we have Base Internationalization. Now may be a good time to move over.

Related

I lost some of my work while refactoring a storyboard on XCode? What can I do?

I have read the First Book from appcoda "Beginning programming with Swift"
One feature that I learned in said book and that I really liked while working with storyboards is the ability to refactor some storyboards when the amount of storyboards becomes too large, so at first I was doing it successfully, no problem whatsoever.
I began dividing my storyboards into smaller chunks like so
OH THE HORROR
then this happened
As soon as I pressed "refactor to storyboards" it didn't prompt me for a name as it did before but instead it renamed the new storyboard reference to "Main copy.storyboard"
Can I recover the storyboard that I lost?
When that happened, the old storyboard dissapeared and an exact copy of the main.storyboard appeared
CTROL-Z Did not work as I tried that immediately and I haven't versioned for the past 2 days or so (I know, that was really stupid)
If I can not recover the storyboard, can someone tell me why did this happen? I don't want to do this again
Btw, I am running the last version of XCode 7.2.1
Xcode may have put the lost storyboard in the Trash. Use the Finder to check. The Trash is the wastebasket-looking thing at the right or bottom end of the Dock.
If the lost file is in the Trash, you may be able to right-click it and choose “Put Back” to send it back into your project folder. You may also need to add it back to your project in Xcode using File > Add Files to “MyProject”.
I got in to the same problem. If you accidentally replaced the original storyboard with new one while refactoring, you can find the old one in project folder with a name ending with "~" symbol.
Hope you can restore it from there.

Switching to Base Internationaliztion

My app is currently localized for English and Japanese, with seperate storyboards for each. I want to switch to base localization so that I only have to maintain a single storyboard. I've checked the "Use Base Internationalization" box in the project's info tab and chosen the English iPhone and iPad storyboards for the base.
I assume I should delete the Japanese iPhone and iPad storyboards I had previously used, but I don't see an option to delete them when right-clicking on their files in the file inspector. Should I delete these old storyboards, and, if so, how?
** Edit **
Changing the 'Main Interface' shown in the screenshot doesn't allow me to delete the Japanese storyboard. It's hard to tell which storyboard to select in the dropdown because its width is more narrow than the storyboard names, but that's a separate issue.
This tutorial drives you through the process step-by-step. This is how it worked for me:
Remove all localizations and leave only the base.
Ensure that the localized files were moved from the project directory (in Finder)
Add the localizations one-by-one
The localized strings are extracted from the storyboard only when the localization is created. The Tutorial above provides a script that can help you keeping the localized files up to date if the storyboard is changed.
In your case, you will have to merge the existing translations into the new files but I suppose it is not a huge deal compared to the gain with using a single file.
For reference, the process is described in this official tutorial too: http://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/chapters/InternationalizeYourApp/InternationalizeYourApp/InternationalizeYourApp.html
After cleaning and reloading, I was able to remove the Japanese storyboards by clicking on the - in the project settings:

Why is my XIB modified every time I open it in IB?

I click on the XIB via the project navigator. It opens up and immediately changes the icon to gray showing I have unsaved changes. If I save changes, click on a different file and click back to re-open it, more changes. Always modifies on open.
It happens with one XIB file in this project and a couple in another project. I'd love to know why it's happening and what I can do to fix it now and prevent it in the future.
Note: using Xcode 3.2 Build 4C199 with Snow Leopard
Edit: I've added a couple sections which got removed from the XML on one of these open/modifications
<key>outlets</key>
<dict>
<key>addEventTabBarController</key>
<string>UITabBarController</string>
<key>window</key>
<string>UIWindow</string>
</dict>
<key>superclass</key>
<string>NSObject</string>
and
<key>outlets</key>
<dict>
<key>courseTableCell</key>
<string>UITableViewCell</string>
</dict>
<key>superclass</key>
<string>UITableViewController</string>
I wound up submitting this issue to Apple. Their response was unenlightening, and talking about possible optimizations, updating meta data for new version of Xcode and the like.
I tracked 100 versions from clicking off and on the file. As Apple said, it was "optimizing" every time, but each time it simply moved some XML tags around. Never happy with it's own optimizations it moved them around the next time they were opened. I'd consider it a bug with Xcode, annoying, but mostly harmless.
This only happened with old XIBs and either moving the contents into a new XIB file or (what really happened) Storyboards got rid of the issue.
I did not want to use storyboards as suggested in one of the other answers.
Here is an alternative simple/quick fix.
Go to the Interface Builder Document Properties on the inspector when selecting the xib view file.
Then you need to
change "Deployment" to something different from Project SDK, in my case I set it to the latest iOS version (iOS 6 currently).
change the development to something different from "Previous version", in my case I set it to the latest Xcode version 4.5
I run Xcode 4.5.2 on Lion.
Hope this helps.
basic Idea...
XCode stores lots of version numbers of all different sorts of things. If you look at the XML representation of the XIB, you should find that the vast majority of these little changes are in these version numbers.
How it happens...
Whenever you do an update of Xcode, many different things within Xcode (and often inside the SDK) get updated. If you make a change to a XIB file, those version changes get stood in the XIB. So, if you happen to open a XIB file, the version changes get put into that file. As soon as you build or run the app, those changed get saved to the file.
But I haven't update Xcode in a while!
Well, whenever you did your last update, the XIB files will be updated with the new version numbers as you open them, one-by-one over time.
Edit XCode 4 is better now, (maybe), if you're tempted to vote this down then ask yourself, "Have I migrated from XCode 3 to XCode 4 using Versioning?" If no, then you have no idea what you're doing, and please don't vote on this. If you have, you know how bad you suffered, but yes this question is otherwise dead. If you do find yourself opening a legacy project, just recreate it and copy the files.
I don't know the exact answer, but I do know these things will help you find it:
XCode 4 is notorious for screwing things up.
If you put your directory into a Versioning system, (Git), then grab GitBox and save your project to give it a state and create a git repo out of it. The git repo will save the state. Gitbox will visually show you the changes.
After opening it, you'll be able to right-click on that file in GitBox and hit "see difference" or "view changes" or whatnot.
You will be auto-scrolled to the lines. If you can relate the XML to the Xib, you can figure out what changes.
I went from Lion to Snow Leopard, so I don't deal with this anymore.

iPhone app opens to black screen after refactor proj name in xCode 4

Guys, i wonder if any one can help - My project was fully working in both the simulator and on a device, however, i renamed the project in xcode 4 (double clicking at the root of the project navigation pane, it was happy to rename any references - but now when i launch the app it only opens to the main window (yes it has outlets, all have outlets etc etc),
no code in the app delegate stops at a break point (even in didFinishLaunchingWithOptions)
so unsure what i could have missed, i have looked at other answers and everyone writes and says "missing outlet" etc.
I have dragged some backed up version of the app delegate that used to work and no difference, what could i be missing.
I do have source control, however currently in the process of merging from VSS to GIT.
thanks
lee
Check your Info.plist for what it uses as it's Main Nib File. Perhaps something changed there? Also, within the nib file itself you might have problematic connections to classes that are still named with the old name.

Localizing resources with xcode 4.0.2

I am having multiple issues trying to localize an app with xcode 4.0.2.
This app was coded initially with previous version, but since I installed the 4.0.2 everything (more or less) has worked, except localization. I have about 10 png's that load in 10 different xibs via UIImageView using Interface Builder. These png's are "correctly" localized, inside the es.lproj folder the spanish ones and in the en.lproj folder the english ones.
The weird thing is that even inside xcode, when I open the xib file, it sometimes shows the english version and sometimes the spanish. ¿?
The xibs are not localized, because there is nothing more to localize in there, just that UIImageView with the png's.
Is it not possible to localize just the png's?
Does anyone know if this issues respond to known bugs?
This png's are named text1.png, text2.png, text3.png ... Could it be something related to the serialized naming?
The default xib when there's no localization is english. When it load it pulls in the english resources. So you need to create the localized xibs in addition to the images. Or, what I'd recommend in your case since it's just 10 images, is to load and set the correct image in viewDidLoad. It'll be easier to maintain since you won't have to update every localized version of the xib for every change you make. Save that headache for when you have more items in one that are localized. :)
Well, I think that I get it...
I have changed the name to the png's. Instead of text1.png -> textone.png, texttwo.png ...
(The name should not be a problem, though)
When changing the names, some of the png's has become red. Even though they were still in the right lang.lproj (ex. en.lproj) folder.
I have created another directory to back-up the files and cut-paste all the "red ones".
Then I have deleted (references and file) these files from xcode.
Using finder, I have pasted each one of these png's inside my main language file. Just to move it again to the xcode resources from there.
After having it in xcode again, I have localized it using the "Localization +" Inspector.
Then, using finder again, I have replaced new "localized" png inside lang.lproj (ex. es.lproj) with the old language png in the back-up folder.
Finally, I have deleted the app in the simulator, cleaned, and Run again.
I did the same process with xib files. And everything works now. I haven't found any way to fix dependencies or paths to files that aparently are ok, but the localization doesn't reach them as expected. I understand that this should not be the way, though.