Hi. Thanks to many of the examples in the forum I have some success in creating a widget. Scriptable is really really awesome!
So far I have been doing the coding and testing work on my iPad with an external keyboard. I am wondering how everyone writes and tests their code. Is it possible to write and test codes on a Linux or Windows machine and then copy the js files to the iOS devices when ready?
I’m maintaining a TypeScript definition file for exactly that purpose.
You can find more info here:
It only works for auto completion, not running your script in node.js.
I’m using VisualStudio Code on Windows. Since I needed quite a lot testing, iCloud drive sync wasn’t fast enough for me, so I used Git for Windows to push the script to a private Gist and used a script to download it on iOS:
One caveat: The script cannot download files into folders, only directly into the documents folder of Scriptable as far as I know. And it has to be run after you’ve pushed with Git otherwise you see an old version.
This is fascinating, thanks for posting. I’ve been trying to find the right solution for syncing as iCloud can be really unstable, especially when syncing the same file between 2 devices (I made a time tracker that uses a txt file as datastore, and have accidentally wiped the day’s data when using on iPad & iPhone). I’ll think about your GitHub download option and see if it makes sense for me.
On the main topic, I recently completed a setup similar to @schl3ck:
TypeScript repo w/ a custom Scriptable .d.ts file for proper typing of Scriptable APIs
Rollup.js to compile TS to JS directly into Scriptable documents folder.
I also use this to combine and minify files – this was a big improvement in my setup, as I used to use importModule extensively and found that often the imported files weren’t yet downloaded, causing the script to fail. Now everything’s compiled into a single package, so it’s either all there or none of it is.
Another cool side effect of rollup is the graph plugin – every time I compile, it updates a .dot file with a dependency graph of all my files.
This new setup has seriously been a game changer for my workflow – files don’t compile if there are type errors, so it’s much rare for me to get broken scripts now. Having typings for all the Scriptable APIs is really convenient, and I’m able to really break down my files into granular components without worrying about the iCloud issues.
I’d like to write a post about this at some point, it’s just tough to find the time. Happy to share more details/my config & type files if requested.
Edit: lol nvm, your typing is waaay cleaner than mine, nice work getting all the text documentation in as comments as well. In reading through I saw the up-to-date JSON version of docs that Simon shared, bookmarked that for later.
Besides making the local development more comfortable, this also enables you to share widgets to others that are automatically updated if a new version is deployed. Great for prototyping actual products.
@PascalBru this boilerplate also has a rollup.js config that seems to work nicely.
I do have one issue though. Hope someone can help.