How do I write code on my laptop in an IDE without it complaining?

I don’t have a fancy iPad with a fancy keyboard, and I can’t imagine being productive coding on my iPhone, so I’d like to write the bulk of my code on my laptop in an IDE such as PyCharm or Webstorm, VS Code, Atom, Vim, or anything really (but in that order of preference).

The only problem is is that it the IDE will complain quite a lot. I totally understand why it would complain about things that are purely Scriptable constructs, and for those I was wondering if there were some kind of stub or header file(s) I could use to teach my IDE the proper interfaces so he doesn’t complain.

But the part I don’t understand is when it complains about things that show up in my autocomplete. This is my first time using Javascript so I’m not sure what is and isn’t part of the standard library, for for example Request (Scriptable) and Request (Mozilla) have different signatures. The second one is what my IDE autocompletes to so I just thought that this was a standard function/class but now I’ve quickly found out it’s not. Scriptable wants me to assign headers to Request.headers but the other version wants me to pass them into the constructor. Could someone kindly explain why these are different? The Scriptable documentation says it is using “ECMAScript 6” and as far as I can tell the one on the Mozilla page is also ECMAScript 6.

Thanks in advance.



So ECMAScript 6 is the JavaScript engine behind the app (in fact behind a lot of apps that use JavaScript on iOS). Implementations of the apps tie into it but in particular, Scriptable has a lot of stuff built on top so that it “bridges” into iOS. That ‘implementation’ aspect may be why there’s some variation on request.

In regards to the IDE, PyCharm is a Python only IDE as far as I know and WebSorm is the JavaScript equivalent from the same software company. WebStorm looks to have an option to define libraries that would allow for the stub aspect you were noting, but I don’t see anything to suggest that there woud be a way to override native JavaScript implementations such as the request one you noted. But it may be that if you define it, it would. It may simply be something not covered on their documentation page. But in theory itt looks like you could create your own libraries for WebStorm and if necessary you could run a transformation on the final code if you needed to say transform a definition for say scriptableRequest to request so that it could be interpreted correctly on iOS.

There’s certainly an element of testing that goes along with the coding. You would potentially have to test on iOS for many things as there’s no iOS replication on your Mac/PC for many things you could be doing on iOS; unless you have an emulator running alongside I guess. It does make me wonder how the round tripping would feel (in terms of friction to development). It may be that round tripping is still more practical than coding on device, and if you are using a Mac then iCloud sync may well be practical. It isn’t a constraint I’ve had to contend with, but I do wonder about what it would be like to be the ain approach.

I am in a position where I write scripts mostly on my iPad (an old(?) 9.7" pro) using a Bluetooth keyboard; but I do also reglarly use the same keyboard (a Logitech K480) with my (plus size 8) iPhone in landscape mode and it isn’t as good, but it is practical. The physical keyboard is absolutely the thing that makes the difference.

Prior to my current keyboard I used a cheap Bluetooth keyboard and a little foldable plastic stand. It was functionally equivalent (lighter in fact, but not as nice to type on) and cost less than 12 GBP from Amazon UK. My point here being that it may be worth trying out something with a keyboard that maybe doesn’t rise to the auspices of being described as “fancy”. It may be a secondary option for native coding on iOS for you beyond the desktop focussed IDE.

It’ll be interesting to see if anyone else is already doing this, and where you plan to take it next. Good Luck! :+1:t2:

1 Like

I’ve been dealing with this exact issue as well. I use VSCode (which allows you to use Typescript type definition files to type check plain javascript, using a jsconfig.json file), so I put together this typings file (feel free to play around with it) a little while back to give me Intellisense for writing Scriptable scripts.

Unfortunately, the Scriptable Request type definition collides with the default lib.d.ts Request type… and the only way I’ve found to force the override of the default type is to disable the lib.d.ts typings altogether… which is no good since I want to use the existing defs for Promise, String, RegExp etc.

I’ve just been dealing with it since I just airdrop the scripts to Scriptable on my phone to run anyways, but if someone figures out a way of overriding the lib.d.ts Request type I would love to hear it!