Still can't export for xliff

Using 7.01. I'm trying all day to export our xliff for localizations. I spoke to several people at WWDC and had hoped most of these issues would be resolved in Xcode 7 - but alas not to be.


What are those issues? Well…I can't even test any of them because I can't export the project! I've already filed a bug, but this is stop-ship for me right now and I've got to twiddle my thumbs.


Everytime I do an export, I get this wonderful error that's totally useless:

9/29/15 1:33:07.878 PM Xcode[28186]: [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-8228/IDEFoundation/Localization/IDELocalizationWork.m:527
Details:  Failed to read strings file "/var/folders/3l/y2j2wt7x4_357qnkmcmbgc700000gn/T/Xcode3SourceStringsAdaptor-2EA23218-33BE-40AD-923B-FA228A574CD6/Localizable.strings", underlying error:
The data couldn’t be read because it isn’t in the correct format.
Object:   <IDELocalizationWork>
Method:   +readStringsWorkForContext:
Thread:   <NSThread: 0x7ffdf0e19730>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.


The file is empty. Great! I thought I remember being told that Xcode 7 wouldn't choke on empty strings files, but obviously that's not the case. OK - lets go through the project looking for any empty localization files. I've got a few thousand files…but I go through every single one and got rid of them all. I have double, triple and quadruple checked. I've run scripts to look for empty strings files, and so on.


Yet I still cannot export my xliff. Sorry but this is simple programming 101 - if I can't process an empty file - don't process an empty file. Why do I have to spend HOURS trying to find empty files for what should be a simple xcode conditional? And why can't the error tell me WHERE its getting this empty file?


OK enough ranting…I'm guessing Xcode is generating this nice empty file for me (boy is that helpful), does anyone else have ideas for what to do next? Otherwise I'm going to strip all localizations from my build and just screw them for now.

We improved the error reporting in Xcode 7.1, which is in beta now. Please try it, and get back to us if it still doesn't work, or if it still gives you error messages that you can't easily act on. Thanks!

I figured it out.


We use a macro in Objective-C for our localized strings in a table. So in Swift we use a function:

public func LocString(aKeyString : String) -> String {
  return NSLocalizedString(aKeyString, tableName: "InformantCommon", bundle: NSBundle.mainBundle(), value: aKeyString, comment: aKeyString)
}


This is it. Please fix it for 7.1 if its not already. I'll amend my bug report.


xcodebuild -exportLocalizations -localizationPath ~/Desktop -project "PocketInformant.xcodeproj"
2015-09-29 15:02:47.809 xcodebuild[80809:8315970] [MT] PluginLoading: Required plug-in compatibility UUID 0420B86A-AA43-4792-9ED0-6FE0F2B16A13 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/ClangFormat.xcplugin' not present in DVTPlugInCompatibilityUUIDs
Bad entry in file /Projects/PocketInformant_Next/Classes/Common.swift (line = 13): Argument is not a literal string.
Bad entry in file /Projects/PocketInformant_Next/Classes/Common.swift (line = 13): Argument is not a literal string.
2015-09-29 15:02:51.436 xcodebuild[80809:8315970] [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-8228/IDEFoundation/Localization/IDELocalizationWork.m:527
Details:  Failed to read strings file "/var/folders/3l/y2j2wt7x4_357qnkmcmbgc700000gn/T/Xcode3SourceStringsAdaptor-435AE366-8D3D-4286-A988-DD89F7B61008/Localizable.strings", underlying error:
The data couldn’t be read because it isn’t in the correct format.
Object:   <IDELocalizationWork>
Method:   +readStringsWorkForContext:
Thread:   <NSThread: 0x7fb8c30068c0>{number = 1, name = main}
Please file a bug at http:/
xcodebuild: error: Localization failed to read a strings file


Xcode should ignore NSLocalizedString with no literal strings.

OK so I exported my xliff. Great! I uploaded it to my localization service and then redownloaded it…and

9/29/15 6:40:28.012 PM Xcode[92294]: [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-9069/IDEFoundation/Localization/IDELocalizationWork.m:487
Details:  Failed to read strings file "/var/folders/3l/y2j2wt7x4_357qnkmcmbgc700000gn/T/Xcode3SourceStringsAdaptor-B655ADD7-FC12-4572-A45C-3FB608F3A7EB/Localizable.strings", underlying error:
The data couldn’t be read because it isn’t in the correct format.
Object:   <Xcode3LocalizedSourceStringsAdaptorTableWorkContext: 0x7fe49ea2a770>
Method:   -work
Thread:   <NSThread: 0x7fe490519ba0>{number = 1, name = main}
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.


It says its another blank file somewhere. The xliff is 10,000 lines…


I tried this in Xcode 7.01 and 7.1.


I went to Xliff because its supposed to make my life easier. I get it, I'm a software developer too…and I deal with all sorts of things with VCF, ICS, VCS, and many other ical type formats that make my nose bleed. So I'm happy to help…its just that these issues I already showed to you guys at WWDC and nearly 6 months later, many betas, and 3 releases later (7, 7.01, 7.1) and the basic "empty file" issues still exist.

OK - same issue with export - I've got go and remove my Swift function for localization.


But it still won't import because of this:


      <trans-unit id="AppCrashStartupMessage">
        <source>Informant appears to be having problems starting up. To help determine the problem please press Help and go to the Logging tab, then press Action to send the logs or database to us with a problem description.
Your database was archived and a fresh new one created. iOS Events were turned off as well.</source>
      <target>Pocket Informant ma problemy z włączeniem się. Aby znaleźć źródło problemu proszę nacisnąć Pomoc następnie przejść do karty logowania, nacisnąć Akcja aby przesłać logi lub bazy danych wraz z opisem problemu.
Twoja baza danych została zarchwizowana, a nowa została już utworzona. Wydarzenia iOS również zostały wyłączone.</target></trans-unit>


xcodebuild: error: The following issues prevented XLIFF import:
Incoming development string " to
" in the project " to
Incoming development string "Informant appears to be having problems starting up. To help determine the problem please press Help and go to the Logging tab, then press Action to send the logs or database to us with a problem description.
Your database was archived and a fresh new one created. iOS Events were turned off as well." does not match "Informant appears to be having problems starting up. To help determine the problem please press Help and go to the Logging tab, then press Action to send the logs or database to us with a problem description.
Your database was archived and a fresh new one created. iOS Events were turned off as well." in the project
Incoming development string "There was an error while upgrading your data.  Informant has archived your database to keep your existing data safe (it is accessible via iTunes File Sharing).


This is text we've had for a long time…and its never been a problem importing via xliff before.

I'm wondering if its the "\r\n" that is in that string. Its the only string we have that has that. Its old and I don't use it anymore … so I'm going to remove it and see if that helps.

Hello,

I'm having the same issue:

     Dec  7 11:23:17 Luisas-MacBook-Pro Xcode[22727]: [MT] DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-9081/IDEFoundation/Localization/IDELocalizationWork.m:487
     Details:  Failed to read strings file "/var/folders/dh/710t9tps66b3d8vfw1v7gg7c0000gp/T/Xcode3SourceStringsAdaptor-D9809DF4-A29D-48F3-A5D6-C0454532CB26/Activity.strings", underlying error:
     The data couldn’t be read because it isn’t in the correct format.
     Object:  <Xcode3LocalizedSourceStringsAdaptorTableWorkContext: 0x7fd8f1b56970>
     Method:  -work
     Thread:  <NSThread: 0x7fd8fbc1a160>{number = 1, name = main}

Did you find any solution?

Thank you

In case anyone else runs into this, the problem is indeed caused by calling NSLocalizedString() with a variable key.


In the past with Objective-C, we'd use a preprocessor macro to simplify things in framework code, like:

#define FW_LOCALIZED_STRING(key, comment) NSLocalizedStringFromTableInBundle(key, @"MyFramework", [NSBundle bundleForClass:[MyClass class], comment)

This doesn't break Xliff export, because the files are pre-processed first, and the macros are expanded.


If instead, you used a method or function, the call to NSLocalizedString( )—and in Swift there's no preprocessor, so a function is the only way to do something like this—the cryptic error results.

AFAIK, the only workaround is to get rid of the wrapper function and use NSLocalizedString( ) (and similar functions) explicitly.

Still can't export for xliff
 
 
Q