美文网首页
sketch开发之Json2View(六) sketch调用SD

sketch开发之Json2View(六) sketch调用SD

作者: 西博尔 | 来源:发表于2019-01-25 14:19 被阅读11次

1.manifest.json 配置

千万不要写"disableCocoaScriptPreprocessor": true
要不然cocoascript后缀的文件没法执行OC格式的代码

2.SDK创建

xcode 创建基于mac的SDK


image.png

3.把framework放到你的.sketchplugin文件中

4.然后代码

var onRun = function(context) {
  log('11111111111111122222222222333333333');
  var doc=context.document;

  var scriptPath = context.scriptPath;
  var pluginRoot = [scriptPath stringByDeletingLastPathComponent];

  var value = loadFramework(pluginRoot,'DES')

  [[[DESManager alloc] init] text];

  log('value ============= ' + value);
}




var loadFramework = function (pluginRootPath, frameworkName) {
  if (NSClassFromString(frameworkName) == null) {
    var mocha = [Mocha sharedRuntime];
    
    return [mocha loadFrameworkWithName: frameworkName inDirectory: pluginRootPath];
  } else {
    return true;
  }
}

SDK代码

image.png

控制台log:

image.png

相关文章

网友评论

      本文标题:sketch开发之Json2View(六) sketch调用SD

      本文链接:https://www.haomeiwen.com/subject/xmbmjqtx.html