Skip to content

Duplicate IDs in ForEach When Using RichTextEditor and Font Toolbar #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
IhorKram opened this issue Apr 3, 2025 · 1 comment
Open
Labels
discussion Discussions not yet turned into an action

Comments

@IhorKram
Copy link

IhorKram commented Apr 3, 2025

I'm encountering multiple runtime warnings when initializing RichTextEditor:

ForEach<Array<RichTextAction>, String, Button>: the ID occurs multiple times within the collection, this will give undefined results!
ForEach<Array<RichTextAction>, String, ModifiedContent<Button, _FlexFrameLayout>>: the ID occurs multiple times within the collection, this will give undefined results!

These warnings appear during the initial setup of the editor.

Additionally, when the toolbar appears and the user taps to edit text style (e.g., to access fonts, colors, and styles), the following error occurs:

ForEach<Array<RichTextAction>, String, Button>: the ID occurs multiple times within the collection, this will give undefined results!

As a result, the navigation bar in the font/style tools view fails to render a Done button, making it unclear how to dismiss the view.

Notes:
The code is directly copy-pasted from the demo app, with no modifications.

The library is integrated via Swift Package Manager.

Please let me know if you'd like a minimal reproducible example or more environment details.

Thanks for your work on this great library!

Image

Image

And RichTextKeyboardToolbar has the same kind of problem...
Image

UPD:
The issue seems to be related to CocoaPods. If I run pod init and pod install (even with an empty Podfile and no pods added) and then open the project via .xcworkspace, the duplicate ID errors occur consistently.

However, after running pod deintegrate and opening the project through .xcodeproj, everything works fine and the warnings no longer appear.

It's worth noting that RichTextKit is still integrated via Swift Package Manager — CocoaPods is not being used to install the library. This suggests that the issue might be caused by an interaction between SwiftPM and the CocoaPods integration layer, even when no pods are installed.

UPD2:
Turns out it's not related to CocoaPods after all. The errors also appear in a project that doesn't use CocoaPods at all.

I then suspected localization might be the cause — and partially, it seems to be. Some projects without localization don't trigger the error, while others still do. So while localization may influence it, it's not the sole reason. The root cause still seems inconsistent and unclear.

@danielsaidi
Copy link
Owner

Thank you for reporting and investigating this @IhorKram 🙌

I'm hoping to get more time with this project in the future, and will take a look at this. Anyone else can also chip in to pinpoint and fix it.

@danielsaidi danielsaidi added the discussion Discussions not yet turned into an action label Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussions not yet turned into an action
Projects
None yet
Development

No branches or pull requests

2 participants