ios Terms and scripting languages - ios

i was looking at several lua/objective-c implementations that looked promising for a project i want to create ,but with an exception that i wanted to be able to download the scripts at runtime.Then i found the terms which state :
"An Application may not download or install executable code. Interpreted code may only be used in an Application if all scripts, code and interpreters are packaged in the Application and not downloaded. The only exception to the foregoing is scripts and code downloaded and run by Apple's built-in WebKit framework."
so clearly you cant download any lua scripts at runtime.
If i interpret correctly you can only run javascript files downloaded through UIWebView.
So if i wanted to create a objective-c/javascript bridge through uiwebkit(with stringByEvaluatingJavaScriptFromString and url encodings) ,i dont see anything against apple's term right?do you think it would be an overkill in perfomance?

I have no experience about the performance of executing Javascript through UIWebView, but I suspect the toll is high if you plan to call stringByEvaluatingJavaScriptFromString with fine grained code. On the other hand, nothing keeps you from loading a full HTML in your UIWebView with all the Javascript code that you need, and this approach would certainly ensure better performance.
actually, there is an alternative approach that you can try and follow. It is actually possible to directly embed the WebKit Javascript Engine (Javascript Core) into your app. This approach has already been "approved" by Apple and you can find it described here. (Dominic Szablewski, the creator of the JavaScript game engine Impact, is the guy who accomplished this).
In short, it comes down to compile the Javascript Core as a static library and then link this in your app. If you don't feel like compiling it yourself, at the link I posted you can also find more information as to how you can license the library from Dominic Szablewski. (I am not really suggesting anything at this respect, just summarizing information).

Related

Where does Chromium load extensions?

I'm trying to get a number of Chrome extensions working in an Electron app. Electron only supports dev tools extensions, so I'm writing code to handle regular extensions more-or-less from scratch. But, I'm getting stuck figuring out what's involved in getting the content scripts to run in the same way they do in Chrome.
In the existing Electron implementation, which is expressly limited to development tool extensions, I traced the code to here, specifically, line 392:
win.devToolsWebContents.executeJavaScript(Extensions.extensionServer._addExtension(${JSON.stringify(extensionInfo)}))
Finding the next step in this process has proved very challenging. I think, but am not certain, that HERE is the corresponding Chromium code, but this seems like it's for development tools extensions in particular (what with the calls to InspectorFrontendHost and the use of iframes).
Could anyone point me in the right direction? Where is the code where Chromium loads the content scripts for regular extensions? Or is this that code?

Instruments UIAutomation core js files location

I'm trying to write some automated tests for my iOS application. Of course, I decided to use Instruments, but its pseudo-IDE sucks. The biggest problem is lack of code completion feature which, as you probably know, is very helpful. Recently I came up with idea, which might be useful. I want to write all these tests in separate IDE, where I can use all its features (like code completion). We can say that it works with one "but". I still don't have code completion for UIALogger, UIAElement, etc.. So I decided to find in my system js files in which these core UIAutomation objects have been defined. Without any success. Does anyone know where are these files? Are they even available in a pure js version?

Dart: Possible to exchange source code on the fly in a running system?

In this article it says: "The Dart VM reads and executes source code, which means there is no compile step between edit and run.". Does that mean that you can exchange source-code on the fly in a running Dart system like in Erlang? Maybe the compiler is removed from the runtime system and then this is no longer possible. So that's why I'm asking.
Dart is run "natively" only in Dartium, which is a flavour of Chrome with DartVM. When you develop an application you still need to compile it it to JavaScript. This way you get fast development lifecycle and in the end you can compile code to JS. Because it's compiled code there is lots more room for compiler to run optimisations on the code. So from my perspective, the compiler is still there and I don't think you would be able to replace code at runtime.
You can send around source code and run it, but it would need to be in a separate isolate. Isolates do have some relationship to Erlang concepts.
The Dart VM doesn't support hot swapping (Called live edit in V8). However, based on mailing list discussions, it sounds like this is something that the authors do want to support in the future.
However, as the others have mentioned, it is possible to dynamically load code into another isolate.

"Run as JavaScript" does not work with my dart web app?

I cannot find the reason why my app does not work when compiled to JavaScript using dart2js. I have tried debugging my compiled JavaScript app using Google DevTools but found it very difficult to understand both the debugger and JavaScript code. You can find my web app on GitHub. I suspect there is a conflict between compiled JavaScript code and imported third party JS libraries such as jquery but not sure. I highly appreciate your help.
The easiest is probably to add a few print statements into your code. With binary search it should be relatively easy to figure out when the VM and dart2js diverge.
Please report back, what the reason was and/or file a bug at http://dartbug.com/ if you believe that dart2js did it wrong.
Solution (as reported by OP): "dart.js should come after [the] app script line".

IOS: AOT ahead of time, what is it?

I have read an article from Xamarin, and came across a particular computer science word : Ahead of Time.
According to some google search result, this AOT does not allow for code generation during run time.
Does it mean, it does not support dynamic stuff?
I know this question may stupid and I have 0 knowledge in IOS, hopefully can get some answer from here. thanks
First, what is the definition of dynamic? For the general public, dynamic code mean the application can change functionality at run-time. For the iOS platform, the binaries are signed to prevent malware. And Apple don't like apps that can load functionality at run-time.
An ahead-of-time (AOT) compiler has nothing to do with dynamic code per se. It's has to do with intermediate language that are just-in-time compilation (JIT). The biggest example of intermediate language is Java bytecode; compile once, run anywhere. When a Java application is executing, the compiled code is JIT to native machine code. AOT compiler is just doing it ahead of time, to save time.
For the iOS platform, Xcode compiles Objective-C to a native binary for the device.
Another way of looking at this is with an example...
In .Net, you can use the Reflection.Emit namespace to generate and compile code at runtime.
Eg you could create an "IDE" with a textbox that accepts C#. When you click a button that C# could be compiled by the .Net framework into a custom library that's loaded dynamically or a fully-fledged executable which is launched as a new process.
This is insanely powerful when combined with the rest of the System.Reflection namespace. You can examine objects at runtime and compile custom code based on any criteria you like.
That said... The problems usually outweigh the benefits in most cases. Mainly, it's a massive security issue, especially when running on a consumer device.
It would be possible to create an app that wouldn't have anything close to malicious code, get it audited by apple, then have the app download code from your webserver, compile it, and execute it. This new code wouldn't be audited...
There really is no good reason to be doing this in a consumer app.

Resources