Search code examples
ioslocalizationxcode7.3nslocalizedstring

XCode 7.3.1 importLocalization crash


Having a complex project with frameworks included we started to meet the issue while using our export/import XLIFF files scripts. The issue was actually around the import script, which threw the next errors:

--- xcodebuild2016-04-13 11:56:20.933 xcodebuild[3927:40233] [MT] DVTAssertions: ASSERTION FAILURE in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-10183.3/IDEFoundation/Localization/IDELocalizationWork.m:177
Details: (group) should not be nil.
Object:
Method: +groupStreamFromFileReference:language:
Thread: {number = 1, name = main}
Hints: None
Backtrace:
0 -[DVTAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:] (in DVTFoundation)
1 _DVTAssertionHandler (in DVTFoundation)
2 _DVTAssertionFailureHandler (in DVTFoundation)

Can anyone suggest me something to get over this bug?


Solution

  • Spending 1 day to find out the Apple fixed some localization crashes in 7.3.1, introduced other bugs as well. So testing the same scripts with 7.2.1 command line tools worked like a charm. But that didn't stop to dig and to find a solution, so here is the flow, which made my scripts run correctly again.

    Input:

    • Project having only localization from code;
    • Several subprojects/frameworks each having a target binary + target unit tests;
    • Assured to remove any Localizable.strings files from your project

    Steps: 1. Select the project and perform a localization export (Editor > Export for Localization..). 2. In my case (but maybe that's just a bug of exporting, which did not include the tag), I had to edit the exported en.xliff file and to add target-language="en" at the end of each <file .. target-language="en"> block. 3. Import back the file (Editor > Import Localizations..)

    But that's not all... Seems that the first export does not export everything all the time(buggy), so you might have to run the same process several times. Each time I exported again, the XLIFF file contained an additional block of localization.

    For example, having a project with app target + unit tests target, the first export process, generated 3 files (2 InfoPlist.strings + 1 Localizable.strings). The next time, the export generated already 4 files (2 InfoPlist.strings + 2 Localizable.strings).

    Whenever exporting from XCode, stopped adding new localization files, my scripts started to work and I could get back to using those.