Yes, I know there are many discussions about this failure. But after checking them out, I think what I have now is different.
In here Error while "Export For Localization.." Xcode 6.3, it says the single quote (') should be replaced as (\') in the strings file.
In here Xcode 6 localization failed to read a strings file, it says that the NSLocalizedString should be commented out (if I understand it right).
To test the problem, I created a new project with 6.3.2 and 6.4(6E23). I can have single quotes in the strings file, but as long as there is NSLocalizedString (e.g. var str = NSLocalizedString("Hi", tableName: nil, bundle: NSBundle.mainBundle(), value: "Hi", comment: "Hi")
) in the view controller file, the Xcode always pops up with
Then I did
xcodebuild -exportLocalizations -localizationPath ./xliff -project testtest.xcodeproj -exportLanguage en
and I get
Bad entry in file ViewController.swift (line = 26): Argument is not a literal string.
2015-06-15 11:08:22.177 xcodebuild[31272:1150546]
[MT] DVTAssertions: Warning in /SourceCache/IDEFrameworks/IDEFrameworks-7718/IDEFoundation/Localization/IDELocalizationWork.m:434
Details: Failed to read strings file "/var/folders/1s/_d08hx4j2gn9t6wlrc5_7gq00000gn/T/Xcode3SourceStringsAdaptor-48CAE246-EBA5-4326-B3C5-B5032A4027D8/Localizable.strings", underlying error:
The data couldn’t be read because it isn’t in the correct format.
Object: IDELocalizationWork
Method: +readStringsWorkForContext:
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.
xcodebuild: error: Localization failed to read a strings file
This error persists even if I comment out Line 26, which is
var str = NSLocalizedString("Hi", tableName: nil, bundle: NSBundle.mainBundle(), value: "Hi", comment: "Hi")
But if I delete Line 26, the error is gone.
So, I guese, the XLIFF generator somehow does not allow "NSLocalizedString" to appear whatsoever??
Have you ever found this like I did?
The reason you get the same behavior whether or not the line is commented out is that localized string detection does not exclude comments and so your NSLocaluzedString call gets discovered and therefore your .strings file is processed and so on.