liamnichols / xcstrings-tool

A plugin to generate Swift constants for your Strings Catalogs.
https://swiftpackageindex.com/liamnichols/xcstrings-tool/documentation/documentation
MIT License
134 stars 24 forks source link

Duplicates in Localizable.xcstrings in 0.2.0 #64

Closed c0dedbear closed 2 weeks ago

c0dedbear commented 3 weeks ago

Hi!

After updating to 0.2.0 of xcstrings-tool-plugin (I use plugin in swift packages inside Xcode project), I've noticed that after build my Localizable.xcstrings were modified by additional strings which duplicates Default Localization values.

I should mention that code base does not have those strings. Catalogs are the source of truth with manual management and used by .localizable.someKey syntax

Screenshot 2024-05-07 at 18 37 51

I found out the exact commit with broken changes https://github.com/liamnichols/xcstrings-tool/commit/15acd617654bc5d903f1a34fd4567b9c90c5787f

So far I fixed the previous commit revision in my project and there is no such issue.

My Xcode version 15.3 and // swift-tools-version: 5.10 in SPM packages.

liamnichols commented 3 weeks ago

Thanks for raising this, i'll take a look! Is your .xcstrings catalog in a Swift Package target, or an Xcode project target?

liamnichols commented 3 weeks ago

(I use plugin in swift packages inside Xcode project)

Oh I see, thanks for confirming.. You might be able to benefit here from disabling the automatic extraction via build settings:

https://swiftpackageindex.com/liamnichols/xcstrings-tool/0.2.0/documentation/documentation/integrating-xcstrings-tool-into-an-xcode-project-target#Configuring-Build-Settings

But it's strange that it started happening in 0.2.0 and not before, probably because I changed the way that the code was generated and Xcode now sees the defaultValue that I pass into the struct initailiser.

I have an idea how to work around this though that I will look into.

liamnichols commented 3 weeks ago

I think that I have a better fix for this in #67... If you can test using the ln/compute-default-value-args branch, that would be helpful 👍

c0dedbear commented 3 weeks ago

@liamnichols thank you for a really quick response! 👏

I switched to ln/compute-default-value-args branch and checked it out. There are no duplicates now, but every Localizable.xcstrings file are modifying by adding one empty string.

It seems your fix definitely solves duplicating 🔥, but probably needs a little polishing 😊

Screenshot 2024-05-08 at 09 55 38

p.s. These settings in my main target/project set as recommended: LOCALIZATION_PREFERS_STRING_CATALOGS): YES LOCALIZED_STRING_SWIFTUI_SUPPORT): NO SWIFT_EMIT_LOC_STRINGS: NO

liamnichols commented 3 weeks ago

Thanks for sharing! I'll look into this more tonight and try to replicate it myself 👍

liamnichols commented 2 weeks ago

Hi again @c0dedbear, I've found a way to avoid this and pushed a new commit to ln/compute-default-value-args.

I think I verified it in the demo app, but if you want to double check that it fixes the issue then please do! Thanks

c0dedbear commented 2 weeks ago

@liamnichols Confirm, everything is good in my project now, thanks!

When do you plan the next release?

liamnichols commented 2 weeks ago

Great, thanks for confirming!

I'll delete that branch now, so please switch to main in the meantime. I'll release a new version either tonight or tomorrow.

Thanks again!

liamnichols commented 2 weeks ago

Released in 0.3.0 🚀