alanrick
alanrick

Reputation: 109

What is the safest way to edit the swiftui String Catalog file directly?

It appears that a comment in my string catalog file causes Xcode to crash when it is rendered in the Source Control Navigator View (yes - it did drive me crazy)

The string is: "X" : { "comment" : "Represents doubled in header\nfrom contract struct",

which was derived from this source code: return String(localized: "X", comment: "Represents doubled in the header")

I suspect the carriage return in the comment is the problem, but I can't remove it. Clearly, this comment is legacy and no longer matches the swiftui source code, but it won't update so my Xcode crashes when trying to submit.

How can I change this comment in the String catalogue?

I tried editing the json file directly but this is ignored. I tried removing the code line and then reading it but the offending comment returns to the string catalog so I guess it's cached somewhere. I tried cleaning the build folder and repeating the above steps - no success, the comment remains and Xcode crashes.

Can I simply drag and drop a duplicate of the string catalog into my project (with the comment corrected) or will that mess up the project?

Version 15.4 (15F31d) on MacBook Air

Upvotes: 0

Views: 165

Answers (1)

Sweeper
Sweeper

Reputation: 270733

I tried editing the json file directly but this is ignored.

That sounds like the localisation key is still managed automatically by Xcode. I would try switching to manual management first, so that Xcode doesn't update it automatically on every build.

In string catalog view, select "Manual" here

enter image description here

Or in JSON:

{
  "sourceLanguage" : "en",
  "strings" : {
    "Foo" : {
      "comment" : "Some Comment",
      "extractionState" : "manual", // <----
      "localizations" : {
        ...
      }
    }
  },
  "version" : "1.0"
}

Upvotes: 2

Related Questions