Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The file “Main.strings” couldn’t be opened because there is no such file.

After attempting to localize a project (originally created in Xcode 6) I am seeing an obscure error in the debug navigator.

Steps performed

  1. Enable Base Localization
  2. Add strings file for an additional language (Portuguese)
  3. Edit the scheme to changing the Application Language and Application Region to Portuguese (Brazil) and Brazil respectively.

Result

"The file “Main.strings” couldn’t be opened because there is no such file."

enter image description here

When attempting to select the file I am presented an alert.

"The document "Main.storyboardc" could not be opened. Interface Builder cannot open compiled nibs."

enter image description here

As a sanity check I created a new project with the same setup (using NSLocalizedString) and ran through the same steps listed above. I provided alternate translations for the additional language, then built and ran the project which worked as expected presenting the alternate translation of strings.

Environment

  • Xcode 7.1.1 (7B1005)
  • OS X 10.11.1 (15B42)

I have already attempted following this answer but the question and answer don't quite apply to the issue I'm seeing.

I'm at a loss here. Any advice?

  • What do the error and alert indicate?
  • Why does one project (created with Xcode 6) fail when attempting to localize and yet a brand new project (created with Xcode 6) succeed?
like image 907
palmi Avatar asked Nov 17 '15 08:11

palmi


2 Answers

I faced the same issue while on a project that was also created on Xcode 6. I resolved the issue in following way without compromising on localization of storyboard file:

  1. Import the XLIFF for localized language (in my case, it was French)
  2. Try to run the app, it will show the mentioned error
  3. Now, right-click on storybook file and click on “Show in Finder”
  4. From the directory location, move out the .storyboard file from Base.lproj folder
  5. Now go back to Xcode, and remove the storyboard file (only reference)
  6. Now, drag the .storyboard file from its new location into the project
  7. Now, add localization from ‘File Inspector’ for .storyboard file. You can use existing .strings file for localization

Everything should work fine now.

like image 138
Vaibhav Misra Avatar answered Nov 08 '22 07:11

Vaibhav Misra


I never found a solution to this problem by using Main.strings. Instead I kept all translatable content in classes allowing me to rely solely on Localizable.strings.

like image 1
palmi Avatar answered Nov 08 '22 08:11

palmi