import-colors-sketch icon indicating copy to clipboard operation
import-colors-sketch copied to clipboard

Import Colors to Color Variables ObjC error

Open rcoldwell opened this issue 2 years ago • 0 comments

In plugin version 2.0.2 when using Import Colors to Color Variables in Sketch v92 after choosing a sketch file to import colors nothing happens. Using the DevTools plugin console I see this error:

MOJavaScriptException: Error: An Obj-C exception occurred.
[native code]
__import.js:1:32056
__import.js:1:32344
__import.js:1:10072
__import.js:1:27641
__skpm_run __import.js:1:36978
__skpm_run [native code]

After reviewing the code in lib/sketch-to-colors.js and looking through sketchplugins.com it appears that converting the filePath before reading the file corrects this issue. I made these changes in a local copy of the plugin and the swatches imported correctly.

const fileURL = NSURL.fileURLWithPath(filePath)  
const error = MOPointer.alloc().init();  
const msDocument = MSDocument.alloc().init();  
msDocument.readFromURL_ofType_error(fileURL, 'com.bohemiancoding.sketch.drawing', error);  

rcoldwell avatar Sep 12 '22 16:09 rcoldwell