Aleš Kocur
Aleš Kocur

Reputation: 1908

Xcode 6 localization failed to read a strings file

Xcode fails to generate xliff localization file with error localization failed to read a strings file. Please check the system log for more details. Does anyone know where do I find these logs? It's Xcode 6.3.2 GM but I've tried the 6.3.1 version as well. With 6.3.1. the error is on specific file but inside that file isn't nothing unusual. Furthermore I've tried to remove that file but I'm getting the same error although the file isn't there anymore. Does anyone idea why?

Upvotes: 5

Views: 5060

Answers (4)

AndreG
AndreG

Reputation: 554

I had a similar problem. Check in the system log for the entry "Xcode: [MT] DVTAssertions". (Applciations->Utilities->Console.app)

For example:

5/13/16 3:08:24.675 PM Xcode[15546]: [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-10188.1/IDEFoundation/Localization/IDELocalizationWork.m:355

Details: Failed to read strings file "Controllers/FindMyPhone/fr.lproj/TILMarkPhoneLostMessageViewController.strings", underlying error:

Comments parser output:

{
    "OGQ-Dm-sLB.text" = "Au secours, je suis perdu**U00A0**! Veuillez appeler mon propri\U00e9taire.";
    "reH-FM-KQF.text" = "Envoyez un message \U00e0 la personne qui trouve votre t\U00e9l\U00e9phoneU00A0; celui-ci s\U2019affiche sur l\U2019\U00e9cran de verrouillage, accompagn\U00e9 de votre num\U00e9ro de t\U00e9l\U00e9phone. ";
}

does not match:

{
    "OGQ-Dm-sLB.text" = "Au secours, je suis perdu\U00a0! Veuillez appeler mon propri\U00e9taire.";
    "reH-FM-KQF.text" = "Envoyez un message \U00e0 la personne qui trouve votre t\U00e9l\U00e9phone\U00a0; celui-ci s\U2019affiche sur l\U2019\U00e9cran de verrouillage, accompagn\U00e9 de votre num\U00e9ro de t\U00e9l\U00e9phone. ";
}

Object: Method: -work Thread: {number = 1, name = main}

Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.

As you can see in my case the problem was related with the 'NO-BREAK SPACE' (U+00A0) unicode character. When exporting for localization, xcode is expecting the code to be \\U00A0, but in my string file is \U00A0 (otherwise the app shows the characters instead of a space...). Sounds like a bug in xcode to me. If you want a quick and dirty solution I would say search in all the project for \U00A0 and replace it for \\U00A0 only for the export (and once you get the xliff undo those changes again).

System log:

System log

Upvotes: 4

MuHAOS
MuHAOS

Reputation: 1128

I had the same problem when tried to use NSLocalizedString with own NSBundle specified. I have fixed this by just redefining the NSLocalizedString function like that:

public func NSLocalizedString(key: String, tableName: String? = nil, bundle: NSBundle = NSBundle.mainBundle(), value: String = "", comment: String) -> String
{
    return yourBundleHere.localizedStringForKey(key, value: value, table: tableName)
}

Replace yourBundleHere with NSBundle.mainBundle() or what ever you want.

Upvotes: 1

skywinder
skywinder

Reputation: 21426

Does anyone know where do I find these logs?

Open Console app. And search in system.log "strings" for example.

Does anyone idea why?

There is a several problems, that cause this error:

  1. Empty Localizable.strings file.

Solution: Just add comment

    /** no localizable strings **/

to this file and problem is gone.

  1. The 2-nd problem in escape symbol: \

Solution: Remove it and figure out something with your special chars. And probably your export process will complete without errors.


P.S.

Upvotes: 7

Aleš Kocur
Aleš Kocur

Reputation: 1908

Well at last, I have solved that by removing all NSLocalizedString macros from code because the xliff exporter looks into code for them and based on results he looks for a strings files. The odd thing is that he scans comments too, so simply comment unwanted NSLocalizedString macros won't help.

Upvotes: 5

Related Questions