Xcode 8 localization import crash

1.1k views Asked by At

Xcode (8.1) is crashing when I import the localizations for my project. It also crashes when I export and then import the same xliff file whithout modification.

Here is the xliff file: http://ge.tt/7J5UY3i2

Here is the full crash report http://pastebin.com/JsJFeCqB. Any tips or workarounds for this?

Application Specific Information:
ProductBuildVersion: 8B62
UNCAUGHT EXCEPTION (NSInvalidArgumentException): -[Xcode3VariantGroup addToTargetDefaultResourcesBuildPhase:]: unrecognized selector sent to instance 0x7fe69615cba0
UserInfo: (null)
Hints: None

Backtrace:
  0   __exceptionPreprocess (in CoreFoundation)
  1   DVTFailureHintExceptionPreprocessor (in DVTFoundation)
  2   objc_exception_throw (in libobjc.A.dylib)
  3   -[NSObject(NSObject) doesNotRecognizeSelector:] (in CoreFoundation)
  4   ___forwarding___ (in CoreFoundation)
  5   _CF_forwarding_prep_0 (in CoreFoundation)
  6   __81+[IDELocalizationWork fileReferenceStreamForName:directoryPath:superitem:target:]_block_invoke (in IDEFoundation)
  7   __33-[IDEStream(IDEStreamMonad) map:]_block_invoke (in IDEFoundation)
  8   __24-[_IDEStreamMap onNext:]_block_invoke_4 (in IDEFoundation)
  9   -[_DVTTimeSlicedMainThreadOrderedUniquingWorkQueue _processWorkItemsWithDeadline:] (in DVTFoundation)
 10   -[DVTTimeSlicedMainThreadWorkQueue _processWithDeadline:] (in DVTFoundation)
 11   -[_DVTTimeSlicedMainThreadActiveWorkQueues _processWorkQueuesOnDeadline] (in DVTFoundation)
 12   __NSFireDelayedPerform (in Foundation)
 13   __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ (in CoreFoundation)
 14   __CFRunLoopDoTimer (in CoreFoundation)
 15   __CFRunLoopDoTimers (in CoreFoundation)
 16   __CFRunLoopRun (in CoreFoundation)
 17   CFRunLoopRunSpecific (in CoreFoundation)
 18   RunCurrentEventLoopInMode (in HIToolbox)
 19   ReceiveNextEventCommon (in HIToolbox)
 20   _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox)
 21   _DPSNextEvent (in AppKit)
 22   -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (in AppKit)
 23   -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in DVTKit)
 24   -[NSApplication run] (in AppKit)
 25   NSApplicationMain (in AppKit)
 26   start (in libdyld.dylib)
3

There are 3 answers

1
Jenszcz On

One of your strings contains double quotes. Try replacing them by " in your untranslated XLIFF file and see if you can re-import that file. This is just a wild guess, and I do not have XCode 8.1 at hand to try and reproduce this myself, but this is the only thing I noticed in your XLIFF file that looked dodgy.

3
Dan Loughney On

This issue kills me. The tool could/should work and make your life so much easier, but it just doesn't. I had this problem over the summer and fixed it with the info.plist tip in the first bullet, but I've recently updated the project and I'm back in xliff exception hell again. On the bright side, my current crash seems to be happening after it finishes doing the work so I am able to keep working.

There are a bunch of things that can go wrong and cause the import to crash. Usually Xcode just blinks out of existence. If you want to see some info before the crash, use xcodebuild:

xcodebuild -verbose -importLocalizations -localizationPath "lang.xliff" -project ./myProject.xcodeproj
  • When you localize, don't add a language directly to an info.plist. Instead add a InfoPlist.Strings file to your project and add the language to that. You may need to manually create the file in each lang.lproj folder. Make sure you don't have an info.plist file in any lang.lproj folder other than base.lproj.

  • When localizing Settings.bundle, create your lang.lproj folders. When you create the Root.strings file, capitalization matters. It must be "Root.strings" otherwise it might work on iOS, but it won't work on the iOS Simulator.

  • Look around in your project structure. After you work with the crashing tool you end up with a bunch of files in the wrong place. You can have a Localized.Strings file in the root group of your project. Remove those.

  • Only use base.lproj instead of en.lproj so manually remove en.lproj files if you find them in the project.

  • the XLIFF file does need to be well formatted, but I don't think that causes a crash.

  • not for you, but supposedly there was a specific crash fixed in Xcode 7 so make sure you are on the latest to avoid that one, at least.

I have some python scripts for living with xliff. They need source path's updated in some of the scripts, but they may help out in the long run: https://github.com/danloughney/xliffHell

0
gutgemeint On

Another hint: Make sure you do not translate CFBundleName and CFBundleDisplayName. XCode will crash during the last step of the import. This issue still exist in XCode 10.3.