Skip to content
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

Not working in Sketch 72.x #33

Open
custa1200 opened this issue May 14, 2021 · 11 comments
Open

Not working in Sketch 72.x #33

custa1200 opened this issue May 14, 2021 · 11 comments

Comments

@custa1200
Copy link
Contributor

I tried to move selected items to the Library and it is not moving them.

@maartenvh
Copy link

Hi @ahmedmigo

Is this plugin still supported? I use it a lot and now it's no longer working since Sketch 72.x
I hope you can update the plugin. Or is there a workaround?

@custa1200
Copy link
Contributor Author

@maartenvh I messaged Ahmed and he has since moved to Figma, so is not longer supporting this, which is a massive pain for me too, it was one of my most useful fave plugins.

@custa1200
Copy link
Contributor Author

custa1200 commented Jul 9, 2021

It looks like this is the issue

New in Sketch 72
Released 5 May, 2021 – read release notes

Changes

The internal class MSApplicationMetadata has been refactored into a new class, BCSketchInfo.

If a plugin was relying on any of the internal methods in MSApplicationMetadata, its code will not work (and may even crash Sketch if it’s passing the returned value unchecked to other parts of its code). The methods that previously lived in MSApplicationMetadata have been replaced with methods in BCSketchInfo.shared(), and most of the metadata you may need is available directly as a dictionary in BCSketchInfo.shared().metadata().

However, as mentioned in our Internal API page, these are internal classes that should never be used.

We recommend using the JavaScript API where possible. Something is missing? Please submit feedback and feature requests.

If I change from "MSApplicationMetadata.metadata().appVersion" to "BCSketchInfo.metadata().appVersion" in this block in the JS file to the following It seems to move ok, I have not done any extensive testing yet though

function localSymbolForSymbol_inLibrary(context, symbol, library) {
  if (BCSketchInfo.metadata().appVersion >= 50) {
    var shareableObjectReference = MSShareableObjectReference.referenceForShareableObject_inLibrary(symbol, library);
    var importedSymbol = AppController.sharedInstance().librariesController().importShareableObjectReference_intoDocument(shareableObjectReference, context.document.documentData());
  } else {
    var importedSymbol = AppController.sharedInstance().librariesController().importForeignSymbol_fromLibrary_intoDocument_(symbol, library, context.document.documentData());
  }

  return importedSymbol.symbolMaster();
}

@custa1200
Copy link
Contributor Author

Ok the above seems to move the component to another library. The Dialog still appears open on the initial file so it is not completing the process. The symbol on the original file is still connected to the symbol in the original file. So it is not connecting to the library and deleting from the original file still.

@custa1200
Copy link
Contributor Author

Actually I never had the new API right, if should have been written as "BCSketchInfo.shared().metadata()", I had missed out the .shared() so it should be

function localSymbolForSymbol_inLibrary(context, symbol, library) {
  if (BCSketchInfo.shared().metadata().appVersion >= 50) {
    var shareableObjectReference = MSShareableObjectReference.referenceForShareableObject_inLibrary(symbol, library);
    var importedSymbol = AppController.sharedInstance().librariesController().importShareableObjectReference_intoDocument(shareableObjectReference, context.document.documentData());
  } else {
    var importedSymbol = AppController.sharedInstance().librariesController().importForeignSymbol_fromLibrary_intoDocument_(symbol, library, context.document.documentData());
  }

  return importedSymbol.symbolMaster();
}

@ColinLondon
Copy link

Still unresolved in Sketch 86. Pity.

@ahmedmigo
Copy link
Owner

Hey Guys.

I lost the source code of the project. if somebody can modify the code I and fix the issues I will merge it to the main branch

@ahmedmigo
Copy link
Owner

@custa1200 How did you manage to get the source code.

It would be great if you can send me a way to reverse the export project so I can fix the issues. because i lost the source code.
or you can email me.

@custa1200
Copy link
Contributor Author

The only code I have is in this repo. When I was asking you about the UI code you said it wasn't needed to fix the issue. I was talking to sketch Help and they are the ones the flagged it incompatible with the most recent releases. The code that you accepted from me worked for only a couple of versions.

@custa1200
Copy link
Contributor Author

I have not looked into things any further to fix again. They suggested I use some feature from the Automate Sketch plugin https://ashung.github.io/Automate-Sketch/ which kinda worked but I found to not work 100% as expected killing a bunch of overrides I had. It really is a shame, your plugin when it was working was a daily lifesaver. I see in the latest beta release notes they are changing their document object model again so I would anticipate there to be issues again after it comes out of Beta. I am sure if you reached out to them directly they might be able to help you?

@Pettrie
Copy link

Pettrie commented Sep 26, 2022

Currently using the plugin: Symbol Swapper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants