Earlier quoted context omitted.
>> I mean Drafts has the ability to download actions (not sure if that is the right term) which are JS that run inside the app. I think this is fine and doesn't skirt any rules, I'm not familiar with that particular app but if that happens it's not fine and it seems to get a pass from Apple. The apps are not allowed to download executable code. You have to bundle it all in the app.
That's not exclusive to that app. Being able to update the app without going through the App Store was one of the big selling points of React Native a few years back. Apps are not allowed to download native code, however.
There is a special entitlement to allow some Apple apps and frameworks to do this — Apple’s JavaScriptCore can do JIT, which requires executing data pages. Similarly, Swift Playgrounds can compile to native code and execute that code
So, for example, you could ship a C compiler on iOS and it would compile perfectly valid binaries, but you would never be able to execute those binaries natively without code-signing them and deploying them in an Apple sanctioned way, which you cannot do on-device (except with the above mentioned exceptions)