liamnichols/xcstrings-tool

Duplicates in Localizable.xcstrings in 0.2.0

Closed this issue ยท 9 comments

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 15acd61

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.

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

(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.

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 ๐Ÿ‘

@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

Thanks for sharing! I'll look into this more tonight and try to replicate it myself ๐Ÿ‘

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

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

When do you plan the next release?

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!

Released in 0.3.0 ๐Ÿš€