I have happy news for you. Friends, I found how to solve the problem.
First, we use the “Select Layers” plug-in and the “Detach Variables” plug-in to delete the variables that do not exist in our file. With this plug-in, we use the “detach variable” plug-in by automatically selecting the instance layers, components and frames. (When using this plug-in, you must apply it to all pages in the file.)
Then, we follow the same path and this time we do “detach deleted variables” with Figma spotlight. (again by selecting layers on all pages)
and bingo!
All variable relationships in your file will be removed. Then, using the “Apply variables” plugin, we match the detached components in our file with our new variable collection.
I think I am quite an expert on the subject and I can help those who cannot do it in their processes.
Oh joy, my 1,000 bug in Figma I’ve come across in the last few years. I copy/paste a single icon from another file (detached as well) and now I have a theme cached that is NOT referenced anywhere in the file, including the single-layer icon with zero reference to the theme from the other file.
Maybe Figma should start outsourcing their bug fixes so they don’t sit in the backlog for years with no resolutions.
Still have this issue as well!! Please fix Figma!
With the redesigned Figma changing the mode is also harder than it used to be, making it super problematic when a component sometimes take over an old mode. A mode that has been delete more than 1 year ago!!!