I'm processing all layer tree to save symbol master ID for instances before I will call detach() for top instance. But I can find a really good method to do it because detach(recursive=true) operates with layer tree in unpredictable.
I tried to save my info in instance layer, but in most cases Sketch detach symbols in a strange way and lost my customised name. Also I tried to use setValue_forKey_onLayer_forPluginIdentifier(), but Sketch also lost it.
I found the only stable way — create a dummy Text layer with name=myinfo and push it to parent children. But it's slow.
Please, help me to find the better way.
P.S. I asked Sketch to fix detach() behaviour, but did't receive any feedback.
Thanks in advise.