我是一名网络开发人员,我想把我的网络产品搬到iPhone上。其中一个产品就像谷歌Maps:在手机屏幕上显示地图,您可以拖动或调整地图的大小,并查看我们添加到地图的一些信息。
我知道有一些技术可以让你使用HTML、CSS和Javascript来开发原生iPhone应用。我列举了一些:
Ansca移动 PhoneGap Appcelerator
还有其他类似的产品吗?它们之间有什么区别?我该选哪一个呢?
我是一名网络开发人员,我想把我的网络产品搬到iPhone上。其中一个产品就像谷歌Maps:在手机屏幕上显示地图,您可以拖动或调整地图的大小,并查看我们添加到地图的一些信息。
我知道有一些技术可以让你使用HTML、CSS和Javascript来开发原生iPhone应用。我列举了一些:
Ansca移动 PhoneGap Appcelerator
还有其他类似的产品吗?它们之间有什么区别?我该选哪一个呢?
当前回答
在你提到的解决方案中,似乎没有一个能让你直接访问OS 3.0中引入的MapKit框架。
由于谷歌Maps HTML小部件远不如MapKit(参见谷歌Latitude的例子),您可能最好开发一个原生Cocoa触摸应用程序,或者选择一个可以扩展以添加MapKit集成的解决方案。PhoneGap以这种方式是可扩展的(它是开源的,所以默认是),其他一些解决方案可能也是如此。
编辑:Titanium现在支持MapKit
其他回答
Rhomobile Rhodes (http://rhomobile.com/products/rhodes)在方法上与PhoneGap非常相似,但它是唯一具有以下功能的框架:
模型-视图-控制器模式(如 大多数web框架提供) 对象关系管理器 支持所有流行的智能手机(包括Windows Phone 7) 托管开发服务(不仅仅是托管构建):http://rhohub.com RhoStudio IDE中的完整调试器和无sdk模拟器 支持同步脱机数据
我参加了一门关于Android/iPhone开发的课程,我们花了8周时间在Titanium上(游戏邦注:版本是Titanium 1.4.2,时间是2010年11月左右)。以下是我的经验。
iPhone Android双重目标
尽管API指南声称该功能在Android和iPhone上都可用,但事实并非如此。很多东西根本无法在某个平台上运行。有些事情是不同的。
A lot of the people in the class has done iPhone applications, and they can not make them work on Android without major rewrites. I developed a simple childrens app called Animap (see android market / Appstore in Sweden) and started developing under Windows. Once the Android target was working I opened the project on OS X. It does not show any build stuff for iPhone, just for Android. You need to start a dual target project under OS X. (Ok, I copied the relevant files to a new project). Next problem - the animations does not work on iPhone (they work on Android). The scrolling events does not work the same on the iPhone. (i.e on Android you get the untouch event when user stops scrolling and releases their finger from the screen, this does not happen on the iPhone).
因为在某些地方没有提到这一点,所以基本上需要先在一个平台上进行试错编程,然后再在另一个平台上进行试错编程。我的意思是,让像Animap这样简单的应用在另一个平台上运行需要大约两天的时间。你还需要有if (android) then…或者(iphone)…在你的代码中…
下载和设置
You must follow the instructions to the letter. Do not try to use java 64 bit. It will not compile the KitchenSink 1.4.0 demo application. (1.3 works OK!) You must put files directly on the C drive as long pathnames will make the external program not receiving all command line parameters if they get to long. (Fine for small programs though) 1/3 of the times, the toolchain simply stops and you must press 'launch' again. Then it will probably work... very unreliable. The simulator will not be found on startup and then you must simply kill of adb.exe with Ctrl+Alt+Delete and retry.
网络连接
在wi - fi网络上,有时会断开实时连接,Titanium会崩溃(编译/部署接口) 如果你没有工作的互联网连接,它将无法启动,因为它不能登录到他们的服务器。
API
与此相比,CSS, HTML和jQuery是一件轻松的事情。Titanium类似于任何其他旧的GUI API,你需要为每个按钮/字段等设置一些属性。得到一个错误的字段只是很容易,记住所有需要设置的属性?你在正确的地方用大写字母拼写了吗?(因为这不会被编译器捕获,但如果你幸运地测试了这部分,将被视为运行时错误)
在Titanium中,当你在控件上添加另一个视图或单击GUI中的其他地方时,事情就会简单地中断。
文档
有几个API页面带有Android符号,但只会在您尝试创建控件时返回null。尽管有这些符号,但它们并不只是在Android平台上可用。有时Android被提到不支持某个特定的方法,但整个API就缺失了。
KitchenSink并
演示应用程序。我是否提到过,如果您将它放在Eclipse项目文件夹中,因为路径太长而无法编译?必须放在C盘的根文件夹里。我目前使用的符号链接(mklink /J…)
无证的方法
你必须合理地使用事物作为标签。setText('Hello World')来更改一个可靠的标签,但这根本没有记录。
调试
Titanium.API.info('打印输出是调试的唯一方法');
编辑
这些api没有任何好的格式,所以你不能在Eclipse中通过帮助等方式获得普通的代码补全。Aptana,请帮帮我!
硬件
似乎编译器/工具不是多线程的,所以一个快速的计算机和一个快速的硬盘驱动器是必须的,因为你必须做大量的试验和错误。我提到过糟糕的文件吗?你必须把那里的一切都试一试,因为你不能相信它!
一些积极的事情
Open Source From previous projects I have promised myself never ever to use closed source again as you can't simply fix things just by throwing hours and manpower at it. Important when you are late in the project and need to deliver for a hard deadline. This is open source and I have been able to see why the tool chain breaks and actually fix it as well. Bugdatabase It's also open. You can simply see that your not alone and do a workaround instead of another 4 hours spent on trial&error. Community Seems to be active on their forums.
Bugs
Titanium 1.4 is not threadsafe. That means if you make use of threads (use the url: property in a createWindow call) and program like the threads are working and send events with data back and forth you run into a lot of very, very strange stuff - lost handlers, lost windows, too many events, too few events, etc. etc. This is all dependent on the timing, putting the rows of code in different order might crash or heal your application. Adding a window in another file.js breaks your app.js execution... This also trashes internal datastructures in Titanium, as they sometimes can update internal datastructures in paralell, overwriting a just changed value with something else.
我在使用Titanium时遇到的很多问题都来自于我使用实时系统的背景,比如支持数百个线程、事件和消息传递的OSE。这应该在Titanium 1.4中工作,但它并不可靠。
Javascript (which is new to me) dies silently on runtime errors. This also means that small and common bugs, like misspelling a variable name or reading in a null-pointer does not crash when it should so you can debug it. Instead parts of your program just stop working, for instance an eventhandler, because you misplaced/misstyped a character. Then we have more simple bugs in Titanium, like some parameters not working in the functions (which is quite common on the Android platform at least). Trial and Error debug cycle speed Having run Titnium Developer on several computers, I noticed that the bottleneck is the harddrive. An SSD drive on a laptop makes the build cycle about 3-5 times faster than on a 4200 rpm drive. On a desktop, having dual drives in RAID 1 (striping mode) makes the build about 25 percent faster than on a single drive with a somewhat faster CPU and it also beats the SSD drive laptop.
总结
从这个帖子里的评论来看,似乎有一场像这样的工具可以提供应用程序的平台数量之争。API的数量似乎是关键的卖点。
当你开始使用它的时候,它会非常闪亮。如果你查看打开的bug跟踪器,你会发现bug数量的增长速度一直快于已修复的bug数量。这通常是开发人员不断添加更多功能的标志,而不是专注于减少错误的数量。
作为一个为客户提供多平台应用的顾问,我不确定这是否比在两个平台上开发本地应用更快。这是因为当你达到速度时,你使用钛的速度很快,但突然你向下看,发现自己在一个如此深的洞里,你不知道必须花费多少小时来解决问题。你可以在特定的期限/时间/成本下不承诺特定的功能。
关于我自己:我已经用wxPython使用Python两年了。(GUI是不一致的,但从未像这样中断。可能是我不理解Javascript和Titanium使用的线程模型,但根据他们的开放论坛,我不是一个人,GUI对象突然使用错误的上下文/不更新..??)在此之前,我有移动设备的C和ASM编程背景。
[编辑-添加了错误的部分,不线程安全] [编辑-现在已经工作了一个多月,主要是在PC上,但也有一些在OS X上。增加了iPhone和Android的双重目标。增加了试错调试周期
在你提到的解决方案中,似乎没有一个能让你直接访问OS 3.0中引入的MapKit框架。
由于谷歌Maps HTML小部件远不如MapKit(参见谷歌Latitude的例子),您可能最好开发一个原生Cocoa触摸应用程序,或者选择一个可以扩展以添加MapKit集成的解决方案。PhoneGap以这种方式是可扩展的(它是开源的,所以默认是),其他一些解决方案可能也是如此。
编辑:Titanium现在支持MapKit
据我所知,这两者之间有一些不同之处:
PhoneGap basically generates native wrappers for what are still web apps. It spits out a WhateverYourPlatformIs project, you build it, and deploy. If we're talking about the iPhone (which is where I spend my time), it doesn't seem much different from creating a web app launcher (a shortcut that gets its own Springboard icon, so you can launch it like (like) a native app). The "app" itself is still html/js/etc., and runs inside a hosted browser control. What PhoneGap provides beyond that is a bridge between JavaScript and native device APIs. So, you write JavaScript against PhoneGap APIs, and PhoneGap then makes the appropriate corresponding native call. In that respect, it is different from deploying a plain old web app. Titanium source gets compiled down to native bits. That is, your html/js/etc. aren't simply attached to a project and then hosted inside a web browser control - they're turned into native apps. That means, for example, that your app's interface will be composed of native UI components. There are ways of getting native look-and-feel without having a native app, but... well... what a nightmare that usually turns out to be.
两者的相似之处在于,您可以使用典型的web技术(html/js/css/等等等等)编写所有内容,并且您可以通过自定义JavaScript api访问本机功能。
但是,同样,PhoneGap应用程序(PhonGapps?我不知道……这名字蠢吗?说起来容易些——我知道这么多)以网络应用开始他们的生活,以网络应用结束他们的生活。在iPhone上,html/js/等等。只是在UIWebView控件中执行,PhoneGap JavaScript api你的js调用被路由到本地api。
钛应用变成了原生应用——它们只是使用web开发技术开发的。
这到底是什么意思呢?
Titanium应用看起来就像一个“真正的”应用,因为归根结底,它就是一个“真正的”应用。 PhoneGap应用程序看起来像一个托管在浏览器控件中的web应用程序,因为归根结底,它是一个托管在浏览器控件中的web应用程序。
哪一种适合你?
如果你想使用web开发技能编写本地应用程序,Titanium是你最好的选择。 如果你想要使用web开发技能编写一个应用程序,你可以实际部署到多个平台(iPhone、Android、黑莓和其他他们决定包括的平台),如果你想通过统一的JavaScript API访问本机平台功能的子集(GPS、加速计等),PhoneGap可能是你想要的。
你可能会问:为什么我要写一个PhoneGapp(我决定使用这个名字),而不是一个托管在网络上的web应用程序?我是否仍然可以通过这种方式访问一些原生设备功能,同时也拥有真正的web部署的便利,而不是强迫用户下载我的“原生”应用并安装它?
答案是:因为你可以将你的PhoneGapp提交到App Store并收费。你还会看到启动器图标,这让用户更难忘记你的应用(比起应用图标,我更容易忘记书签)。
You could certainly charge for access to your web-hosted web app, but how many people are really going to go through the process to do that? With the App Store, I pick an app, tap the "Buy" button, enter a password, and I'm done. It installs. Seconds later, I'm using it. If I had to use someone else's one-off mobile web transaction interface, which likely means having to tap out my name, address, phone number, CC number, and other things I don't want to tap out, I almost certainly wouldn't go through with it. Also, I trust Apple - I'm confident Steve Jobs isn't going to log my info and then charge a bunch of naughty magazine subscriptions to my CC for kicks.
不管怎样,除了涉及到web开发技术之外,PhoneGap和Titanium是非常不同的——只有表面上的可比。
I hate web apps, by the by, and if you read iTunes App Store reviews, users are pretty good at spotting them. I won't name any names, but I have a couple "apps" on my phone that look and run like garbage, and it's because they're web apps that are hosted inside UIWebView instances. If I wanted to use a web app, I'd open Safari and, you know, navigate to one. I bought an iPhone because I want things that are iPhone-y. I have no problem using, say, a snazzy Google web app inside Safari, but I'd feel cheated if Google just snuck a bookmark onto Springboard by presenting a web app as a native one.
我得走了。我女朋友脸上有一种"拜托你别再用电脑三秒钟"的表情。
Titanium支持native mapkit