碰巧的JavaScript code有什么用二手机编译应用程序后, [英] What happens to JavaScript code after app is compiled using Titanium Mobile

查看:242
本文介绍了碰巧的JavaScript code有什么用二手机编译应用程序后,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Appcelerator的安装钛和建成的KitchenSink示例应用程序。

I installed Titanium from appcelerator and built the "KitchenSink" example application.

一切运作良好,我只是想知道哪里来的JavaScript code结束了在内置的应用程序。

All works well, I'm just wondering where does the javascript code ends up in a built app.

我用grep-ED在X code项目,也是其结果应用程序,我发现它在库/应用​​程序支持/ iPhone模拟器/ .... KitchenSink.app <​​/ code>,但我找不到从的.js 文件,在应用程序中使用甚至没有字符串文本任何函数名。

I grep-ed the Xcode project and also the result application as I found it in Library/Application Support/iPhone Simulator/....KitchenSink.app, but I can't find any function names from .js files, not even string texts used within the application.

我发现最近的信息是一个答案在这里:如何进行Appcelerator的钛移动工作< /一>,但我不明白清楚如何处理工作。

Nearest information I found is an answer here : How Does Appcelerator Titanium Mobile Work? but I do not understand clearly how the process works.

是JavaScript code被编译成二进制code(用什么编译器呢?),还是仅仅是变换PTED在运行的应用程序的一些特殊的数据格式,跨$ P $?

Is the javascript code being compiled into a binary code (what compiler is used then?), or is it just transformed in some special data-format and interpreted in a running application ?

更新:

这是我能在的KitchenSink的生成/ android的目录中看到:

This is what I can see in a build/android directory of KitchenSink:

michal:bin mac$ find . -name table_view_layout\*
./assets/Resources/examples/table_view_layout.js
./assets/Resources/examples/table_view_layout_2.js
./assets/Resources/examples/table_view_layout_3.js
./assets/Resources/examples/table_view_layout_4.js
./assets/Resources/examples/table_view_layout_5.js
./classes/org/appcelerator/generated/examples/table_view_layout.class
./classes/org/appcelerator/generated/examples/table_view_layout_2.class
./classes/org/appcelerator/generated/examples/table_view_layout_3.class
./classes/org/appcelerator/generated/examples/table_view_layout_4.class
./classes/org/appcelerator/generated/examples/table_view_layout_5.class
michal:bin mac$ unzip -t app.apk | grep table_view_layout
    testing: assets/Resources/examples/table_view_layout.js   OK
    testing: assets/Resources/examples/table_view_layout_2.js   OK
    testing: assets/Resources/examples/table_view_layout_3.js   OK
    testing: assets/Resources/examples/table_view_layout_4.js   OK
    testing: assets/Resources/examples/table_view_layout_5.js   OK

我没有考虑app.apk之前,我能看到是对应于每个javascript文件,这些类文件。因此,我认为在Android上的JavaScript被编译为JVM。为什么不能在app.apk这些被发现的?

I didn't look into app.apk before, all I could see were these class files corresponding to each of the javascript files. Therefore I assumed that on Android javascript is being compiled for JVM. Why can't these be found in app.apk ?

推荐答案

二是周围没有像以前那样说(虽然这准确地解释了PhoneGap的工作方式)的网络视图的包装。杰夫的回答,在这个问题联系在一起,是钛是如何工作的一个技术上正确的解释,但这里是我听过的最好的版本,到目前为止,从马歇尔卡尔佩珀

Titanium is not a wrapper around a web view as stated before (though that accurately explains how Phonegap works). Jeff's answer, linked in the question, is a technically correct explanation of how Titanium works, but here's the best version I've heard so far, from Marshall Culpepper:

这是真的,二手机使用的web视图(在Android和iOS)在pre-1.0天。但是,这已不再是真实的,并没有得到,因为我们的1.0版本是2010年3月。

It's true that Titanium Mobile used the WebView (in both Android and iOS) in the pre-1.0 days. However, this is no longer true and hasn't been since our 1.0 release is March 2010.

1.0以来,我们已经发运两个单独的Javascript运行时与我们的应用程序,我们正在运行Javascript的code直接没有的WebView。你从开始到结束的整个应用程序现在被JS控制的,我们提供了一个COM prehensive组原生API,使这一点。从UI部件一切(当然,也包括web视图),核心API,如网络,文件系统,数据库,一路像Android的JS活动OS特有的东西。在JS运行前,我们航运WebKit的JavaScriptCore的在iOS的分支版本和犀牛1.7 R3 CVS的对于Android的快照。我们居然跟你的JavaScript源做的是依赖于平台,但通常它打破了这样的:

Since 1.0, we've shipped two separate Javascript runtimes with our apps, and we are running the Javascript code directly without a WebView. Your entire app from start to finish is now controlled by JS, and we provide a comprehensive set of Native APIs that enable this. Everything from UI widgets (yes, including WebView), Core APIs like Networking, Filesystem, Database, all the way to OS-specific things like JS Activities in Android. On the JS runtime front, we're shipping a forked version of WebKit's JavaScriptCore in iOS and a snapshot of Rhino 1.7 R3 CVS for Android. What we actually do with your javascript source is dependent on the platform, but generally it breaks up like this:

  • 在源代码静态分析,发现提及钛模块
  • 在本地化字符串(strings.xml中),应用程序的元数据(tiapp.xml),和密度特定图像的所有生成特定平台的类似物。
  • 在iOS的:
    • 在生成的X code项目/配置
    • 在JS源是base64'd和内联作为变量到生成的C文件
    • X codebuild用于生成最终的二进制文件
    • 在配置配置文件,签署密钥等应用
    • 在iTunes和其他一些胶水用于国际音标发送到您的iOS设备
    • Source is statically analyzed to find references to Titanium modules
    • Localization strings (strings.xml), App metadata (tiapp.xml), and density specific images all generate platform specific analogs.
    • In iOS:
      • An XCode project / configuration is generated
      • JS Source is base64'd and inlined as a variable into a generated C file
      • xcodebuild is used to generate the final binaries
      • provisioning profiles, signing keys etc are applied
      • iTunes and some other glue are used to send the IPA to your iOS device
      • 生成一个Android / Eclipse项目
      • 在发展模式,JS源被打包为APK资产
      • 在分配(生产)模式,当你准备出货的应用程序,我们编译使用犀牛JSC编译器的JS为Java字节code。您还可以在开发模式在tiapp.xml设置ti.android.compilejs为true启用此功能,请参见:<一href="http://developer.appcelerator.com/question/100201/enable-android-byte-$c$c-compile">http://developer.appcelerator.com/question/100201/enable-android-byte-$c$c-compile
      • DEX,AAPT,和其他Android SDK工具用于构建和生成最终的APK
      • 在亚洲开发银行和密钥工具用于推动APK出仿真器和/或设备
      • An Android / Eclipse project is generated
      • In "Development" mode, JS source is packaged as APK assets
      • In "Distribution" (production) mode, when you're ready to ship the app, we compile the JS to Java bytecode using the Rhino JSC compiler. You can also enable this during development mode by setting "ti.android.compilejs" to "true" in tiapp.xml, see: http://developer.appcelerator.com/question/100201/enable-android-byte-code-compile
      • dex, aapt, and other Android SDK tools are used to build and generate the final APK
      • adb and keytool are used for pushing the APK out to the emulator and/or device

      有更多的细节,我可以潜入专门对每个点的,但是我想开车回家的一点是,我们不再使用的WebView作为我们的Javascript引擎。您可以但是仍然嵌入WebViews,和我们提供一些简单的集成,使您可以从一个嵌入的WebView叫钛的API。

      There are many more details that I could dive into specifically on each of these points, but the point I wanted to drive home is that we no longer use the WebView as our Javascript engine. You can however still embed WebViews, and we provide some simple integration that allows you to call Titanium APIs from an embedded WebView.

      这篇关于碰巧的JavaScript code有什么用二手机编译应用程序后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆