Xcode Import For Localizations Missing Resource in Import error
Asked Answered
T

1

9

After having our app translated in a few languages, we realized that there were a couple .strings files that had been included in the .xliff files that were not needed to be translated, so they could be deleted.

So, I unchecked the localization option for those languages in Xcode and deleted the .string files.

However, now whenever I import a .xliff file it still somehow things in it missing localization for those files we don't want anymore.

enter image description here

Importing will crash Xcode.

Even doing an Export for Localizations will reference those .strings files that are nowhere anymore.

Where in our Xcode project could those files be still referenced? I can't import localizations until I get this fixed.

Trelu answered 27/3, 2016 at 18:46 Comment(3)
Are you able to fix this problem?Same scenario i faced.Harvison
@Harvison - I ended up removing all the NSLocalizedStringFromTable and replaced them with NSLocalizedString. That worked for me.Trelu
I was able to just press import and it got imported without any problem. For me that was the only error message there. I am using iOS 11 though, Apple may have fixed this.Talc
B
0

I've got the same issue, for me it was caused by incorrect paths in xliff itself.

Check the original attribute in files

<file original="..." source-language="en" target-language="cs">

for me it has the path that included the root directory (e.g. "ProjectDir/Resources/..." instead of "Resources/..."). This blocked import.

In your case

I assume you'll have to go through xliff files and find that reference strings that you deleted and remove such blocks (<file original="path/to/deleted.strings">...</file>)

In general

I've written a simple bash script that expects all affected files as arguments and modifies the original attribute in case contains invalid path:

for file in "$@"
do
   sed -i '' -E "s#original=\"**ProjectDir**/#original=\"#g" "$file"
done

Replace ProjectDir with whatever your root folder is (or any extra parent folders) and it will be trimmed.

Note that it will edit passed files, so make sure you have a backup.

Boot answered 5/5, 2022 at 10:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.