To my knowledge, the reason no “real” terminal exists for iOS is because it violates the App Store rules. It is prohibited to download and execute arbitrary code, with a few exceptions.
One exception is JavaScript, which must be run inside of JavaScript Core [1]. What if someone simulated x86 and Linux _in JavaScript_ and then built a terminal and file system on top of it? Would that be in accordance with the App Store rules (since it would be sandboxed in Apple’s JS core)? Would it even be technically feasible? Or too slow for any serious usage?
[1] from the App Store rules:
4.7 HTML5 Games, Bots, etc.
Apps may contain or run code that is not embedded in the binary (e.g. HTML5-based games, bots, etc.), as long as code distribution isn’t the main purpose of the app, the code is not offered in a store or store-like interface, and provided that the software (1) is free or purchased using in-app purchase; (2) only uses capabilities available in a standard WebKit view (e.g. it must open and run natively in Safari without modifications or additional software); your app must use WebKit and JavaScript Core to run third-party software and should not attempt to extend or expose native platform APIs to third-party software; (3) is offered by developers that have joined the Apple Developer Program and signed the Apple Developer Program License Agreement; (4) does not provide access to real money gaming, lotteries, or charitable donations; (5) adheres to the terms of these App Review Guidelines (e.g. does not include objectionable content); and (6) does not offer digital goods or services for sale. Upon request, you must provide an index of software and metadata available in your app. It must include Apple Developer Program Team IDs for the providers of the software along with a URL which App Review can use to confirm that the software complies with the requirements above.
It is not necessary to resort to JavaScript for the emulation, emulation and interpretation are allowed. App Store effectively forbids the usage of JIT (so VMs do not run as fast as one could expect) and running any code that’s not included in the package at the time you submit the app for review (with an exception for educational apps).
I’m not doubting you, but I don’t see where in the App Store rules it forbids JIT, other than the prohibition of running third-party code. Emulation and interpretation are allowed — if the code is first- or second- party.
Educational apps are an interesting exception, but as I quoted in my patent comment, JavaScript is the other major one.
So I wonder if JIT compilation and execution is possible under the rules in JavaScript? (Again, is that even feasible?)
Generally, JIT requires the ability to execute data (writeable memory pages that contain code). iOS apps need a special system permission (in Apple's terminology — entitlement) to construct such pages. To my knowledge, no apps except for the first-party ones (like Safari) have this permission.
Apps can call into one system API that has this JIT capacity (WKWebView). It runs in a separate process and uses IPC to communicate with the app. It has an API that allows the application to execute arbitrary JS code at full speed. Some time ago it lacked support for WebAssembly, but it may have been resolved by now.
So, these are the technical limitations of the platform. Apple chose to implement a number of arbitrary rules on top of that. Well, it's not a democracy, and they are free to do so. There is always a slight chance of having some form of less restricted execution environment in future versions of iOS, mainly due to how much their iPad Pro hardware is overpowered relative to the OS capabilities.
This was also discussed here a few months ago by the author of utmapp (Qemu on iOS). In order to get their code to work, they need to effectively run their own code in debugging mode. And yes, this requires the same entitlement as the JS JIT.
To my knowledge, the reason no “real” terminal exists for iOS is because it violates the App Store rules. It is prohibited to download and execute arbitrary code, with a few exceptions.
One exception is JavaScript, which must be run inside of JavaScript Core [1]. What if someone simulated x86 and Linux _in JavaScript_ and then built a terminal and file system on top of it? Would that be in accordance with the App Store rules (since it would be sandboxed in Apple’s JS core)? Would it even be technically feasible? Or too slow for any serious usage?
[1] from the App Store rules:
4.7 HTML5 Games, Bots, etc. Apps may contain or run code that is not embedded in the binary (e.g. HTML5-based games, bots, etc.), as long as code distribution isn’t the main purpose of the app, the code is not offered in a store or store-like interface, and provided that the software (1) is free or purchased using in-app purchase; (2) only uses capabilities available in a standard WebKit view (e.g. it must open and run natively in Safari without modifications or additional software); your app must use WebKit and JavaScript Core to run third-party software and should not attempt to extend or expose native platform APIs to third-party software; (3) is offered by developers that have joined the Apple Developer Program and signed the Apple Developer Program License Agreement; (4) does not provide access to real money gaming, lotteries, or charitable donations; (5) adheres to the terms of these App Review Guidelines (e.g. does not include objectionable content); and (6) does not offer digital goods or services for sale. Upon request, you must provide an index of software and metadata available in your app. It must include Apple Developer Program Team IDs for the providers of the software along with a URL which App Review can use to confirm that the software complies with the requirements above.