1.manifest.json 配置
千万不要写"disableCocoaScriptPreprocessor": true
要不然cocoascript后缀的文件没法执行OC格式的代码
2.SDK创建
xcode 创建基于mac的SDK
![](https://img.haomeiwen.com/i2305823/97c696259fd65084.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代码
![](https://img.haomeiwen.com/i2305823/ff26bcb20891b05a.png)
控制台log:
![](https://img.haomeiwen.com/i2305823/b866c9046a6ce3e4.png)
网友评论