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;
}
}
网友评论