How to solve erros when Load Plugin(XD) on UXP?

I’m having problems with UXP when I’m going to load a plugin, it’s the first time I’m using the tool. Adobe’s own support asked me to post it here because they couldn’t direct me.
Something I might have done wrong installing something?

Does your manifest.json file specify a higher-numbered version of XD?

Here is my manifest.json, I took a sample to test but to no avail

{
“id”: “useall-tdu-2”,
“name”: “Hello World sample plugin”,
“version”: “0.0.1”,
“description”: “Description of your plugin.”,
“summary”: “Summary of your plugin”,
“languages”: [“en”],
“author”: “Your Name”,
“helpUrl”: “https://mywebsite.com/help”,
“host”: {
“app”: “XD”,
“minVersion”: “13.0”
},
“uiEntryPoints”: [
{
“type”: “menu”,
“label”: “Create Rectangle”,
“commandId”: “createRectangle”
}
]
}

  1. Do you have any documents open in Adobe XD? I tried it and it seemed to fail if there were no documents.

  2. Does main.js exist in the same folder?

  3. Is there a function in main.js that matches the id specified in manifest.json?

// main.js example

const doSomething = () => {
  // do something
} ;

module.exports = {
  commands: {
    createRectangle: doSomething
  }
} ;

Yes there is

I created the same manifest.json, main.js as yours and tried to load it, with success.

Environment:

  • macOS 11.7
  • Adobe XD (55.0.12.9 arm64)
  • Adobe UXP Developer Tool (1.7.0.13)

The failure may be the difference between Windows and macOS, or there may be something wrong with the actual file. Can you share the actual data that is not an image?

>>> manifest.json <<<

{
“id”: “useall-tdu-2”,
“name”: “Hello World sample plugin”,
“version”: “0.0.1”,
“description”: “Description of your plugin.”,
“summary”: “Summary of your plugin”,
“languages”: [“en”],
“author”: “Your Name”,
“helpUrl”: “https://mywebsite.com/help”,
“host”: {
“app”: “XD”,
“minVersion”: “38.0”
},
“uiEntryPoints”: [
{
“type”: “menu”,
“label”: “Create Rectangle”,
“commandId”: “createRectangle”
}
]
}

>>> main.js <<<

// [1]
const { Rectangle, Color } = require(“scenegraph”);

// [2]
function rectangleHandlerFunction(selection) {
// [3]
const newElement = new Rectangle();
newElement.width = 100;
newElement.height = 50;
newElement.fill = new Color(“Purple”);

// [4]
selection.insertionParent.addChild(newElement);
// [5]
newElement.moveInParentCoordinates(100, 100);
}

// [6]
module.exports = {
commands: {
createRectangle: rectangleHandlerFunction,
},
};

//---------------------------

These are the two files I have in my plugin folder.
I just noticed that in the “app logs” tab I have an error and some other alerts, but I couldn’t find any possible errors in my files in front of the warnings:

[2022-11-01 18:10:01:141] [general] The message could not be dispatched on the thread dispatcher_->TryRunAsync
[2022-11-03 07:55:54:251] [general] Plugin rejected - useall-tdu-2 due to invalid object
[2022-11-03 09:32:45:986] [general] We are going to deprecate HostInfo API soon, please use HostApi instead.
[2022-11-03 09:32:46:007] [general] We are going to deprecate HostInfo API soon, please use HostApi instead.
[2022-11-03 09:32:46:030] [general] We are going to deprecate HostInfo API soon, please use HostApi instead.
[2022-11-03 09:32:46:044] [general] We are going to deprecate HostInfo API soon, please use HostApi instead.

While I was writing this message the plugin just loaded by itself, the errors disappeared from the console. Apparently problem solved, but no clear cause…
:neutral_face:

So I removed the plugin, and I try to add it again, the error comes again…

I fixed the indentation of the manifest.json after I kept getting this error in the app logs:
[2022-11-03 09:42:30:802] [general] Plugin rejected - useall-tdu-2 due to invalid object

And I added it again, I tried to load it again and I got the same error, I came back here to report and I kept trying to load the file, and out of nowhere and it loaded again. I do not know what happens…
It seems like some delay, or time to read the files, which I would say is strange considering the files are super light.

I believe it is something related to the indentation of the files, even though it is a valid json it is giving this problem when the indentation is not correct.

Well, continue my studies here in the tool…

Using the text you shared (I replaced the quotes with programmatic ones), I loaded it. The indentation remained the same, but the result was successful.

As you say, I don’t see a clear cause for the failure.

1 Like