去年から待ちかねていた Jonathan Stark の本がやっと届いた。
先に紹介した「HTML や CSS、JavaScript を使って iPhone アプリを作る」の作者が書いた本だ。
最初に知ったときはショックだった。
Objective-C や Cocoa を使わないで、 HTML や JavaScript だけで iPhone のネイティブアプリが出来るというのだ。もしそうなら、スタンフォード大の入門講座で四苦八苦したのはナニ?
Stark 本は、HTML、CSS、JavaScript というオープンソースの Web 技術の知識さえあれば、iPhone のネイティブアプリ作成が可能という立場にたって、そのやり方を解説している。
Building Iphone Apps With Html, Css, and Javascript: Making App Store Apps Without Objective-c or Cocoa: Jonathan Stark: 洋書 | Amazon.co.jp
Jonathan Stark については前にも一度 PhoneGap に関連して触れたことがある。
PhoneGap:Objective-C を知らなくても iPhone ネイティブアプリの開発が可能 | maclalala2
なお、本書については O’Reilly のサイトで全文を読むことができる。
Building iPhone Apps with HTML, CSS, and JavaScript | Oreilly.com
「まえがき」にはなぜ Stark がこの本を書こうと思ったか率直に書かれていて大変おもしろいので、以下紹介してみたい。[Oreilly.com の “Preface” の部分]
* * *
恋に落ちた
何百万というひとたちと同じく私もすぐさま iPhone と恋に落ちた。最初のころは、iPhone に特化したアプリを作る唯一の方法は Web アプリだけだった。私は Web デベロッパだったからそれでよかった。数か月後に App Store が発表されたときは興奮した。本屋に駆け込んで市販の Objective-C に関する本をすべて買い込んだ。私の Web アプリはすでにいくつか売れていた。だからネイティブアプリに書き替えて、App Store に出しさえすれば、波に乗ってしこたま稼げると思ったのだ。
Like millions of people, I fell in love with my iPhone immediately. Initially, web apps were the only way to get a custom app on the device, which was fine by me because I’m a web developer. Months later when the App Store was announced, I was jacked. I ran out and bought every Objective-C book on the market. Some of my web apps were already somewhat popular, and I figured I’d just rewrite them as native apps, put them in the App Store, and ride off into the sunset on a big, galloping pile of money.
* * *
Objective-C は難しかった
しかしそれは幻滅に変わった。Objective-C を学ぶのはとても難しかった。それにマックのプログラミング以外ではこの言語はほとんど役に立たないという事実に気付いて興味が失せてしまった。Xcode や Interface Builder はなかなかよく出来ていたが、これまで習熟していたオーサリングツールとは違っていて、なかなか慣れることができなかった。iPhone でテストするだけなのにセットアップの手間が掛かりすぎることには頭にきた。 App Store にアプリを出すための手続きはこれまたゴチャゴチャしていた。これらの点について1~2週間格闘した挙げ句、どうしてこんなに苦労しなければならないのかと考えてしまった。自分の Web アプリは世界中どこでも手に入るのに、なぜ App Store なんかに出したりする必要があるのだろうか、と。
Disillusionment followed. I found it difficult to learn Objective-C, and I was turned off by the fact that the language was of little use outside of Mac programming. Xcode and Interface Builder were pretty slick, but they weren’t my normal authoring environment and I found them hard to get accustomed to. I was infuriated by the hoops I had to jump through just to set up my app and iPhone for testing. The process of getting the app into the App Store was even more byzantine. After a week or two of struggling with these variables, I found myself wondering why I was going to all the trouble. After all, my web apps were already available worldwide—why did I care about being in the App Store?
* * *
App Store の難関
それに加えて、アップルはアプリを拒否することが可能であり、実際そうしている。これは彼らの特権だから、そうする理由があるのだろう。しかし外部から見れば、気まぐれかつ恣意的に思えてしまう。実際に起きたつぎのようなケースを考えてみてごらん。Objective-C を学ぶのに 100 時間も費やし、さらに 100 時間ほどかけて iPhone のネイティブアプリを作る。それからあなたのアプリはヤマ場を迎える。App Store への提出まで漕ぎ着けたのだ。それから何が起きるか?
On top of all this, Apple can—and does—reject apps. This is certainly their prerogative, and maybe they have good reasons. However, from the outside, it seems capricious and arbitrary. Put yourself in these shoes (based on a true story, BTW): you spend about 100 hours learning Objective-C. You spend another 100 hours or so writing a native iPhone app. Eventually, your app is ready for prime time and you successfully navigate the gauntlet that is the App Store submission process. What happens next?
* * *
苦労は水の泡
あなたは待つ。そして待つ。さらに待つ。ときに数週間、場合によっては数か月待つのだ。やっと連絡が来る・・・あなたのアプリは拒否されました、と。さあ、どうする?これまでの苦労は水の泡だ。
You wait. And wait. And wait some more. We are talking weeks, and sometimes months. Finally you hear back! And…your app is rejected. Now what? You have nothing to show for your effort. The bubble.
* * *
座して見守るのみ
しかし待てよ、もっとひどいこともある。ようやくアプリが承認されたとしよう。数百、あるいは数千のユーザーがアプリをダウンロードしてくれる。入金はまだだが、うれしくて夢見心地だ。それからバグレポートが来始める。バグを見つけ、数分で直し、再度 iTunes ストアに提出する。修正版が承認されるのを待つ。そして待つ。さらに待つ。怒ったユーザーがひどいレビューを App Store に書き込む。売れ行きは頭打ちになる。それでも待つ。怒ったユーザーに払戻も検討する。しかし App Store ではそれは不可能だ。あなたの評価が下がっていくのをただ座して見守るしかない。バグフィックスは数日、数週間前にとっくに済んでしまったというのに・・・
But wait, it can get worse. Let’s say you do get your app approved. Hundreds or maybe thousands of people download your app. You haven’t received any money yet, but you are on cloud nine. Then, the bug reports start coming in. You locate and fix the bug in minutes, resubmit your app to iTunes, and wait for Apple to approve the revision. And wait. And wait some more. Angry customers are giving you horrible reviews in the App Store. Your sales are tanking. And still you wait. You consider offering a refund to the angry customers, but there’s no way to do that through the App Store. So you are basically forced to sit there watching your ratings crash even though the bug was fixed days or weeks ago.
* * *
リスキーな試み
この話はあるデベロッパの実際の経験に基づいたものだ。例外的なケースかもしれないし、実際の統計数字はこれとは違うかもしれない。しかし問題があることは確かだ。我々デベロッパはアップルのデータにアクセスできないし、App Store の承認手続きの詳細も分らないのだ。事態が好転するまでは Objective-C でネイティブアプリを作るのはリスキーな話だ。
Sure, this story is based on the experience of one developer. Maybe it’s an edge case and the actual data doesn’t bear out my thesis. But the problem remains: we developers have no access to Apple’s data, or the real details of the App Store approval process. Until that changes, building a native app with Objective-C is a risky proposition.
* * *
いいとこ取り
幸いなことに別の方法がある。オープンソースの標準的な Web 技術を使って Web アプリを作ればいいのだ。Web アプリとしてリリースし、実際のユーザーでデバッグし、テストする。すべての準備が整ったところで、PhoneGap を使って Web アプリを iPhone のネイティブアプリに変換し、 App Store に提出するのだ。たとい最終的には拒否されても、それで全てが終わるわけじゃない。なぜなら Web アプリの形で提供する道が残されているからだ。もし App Store で承認されたら、それは素晴らしいことだ!そのときは Web アプリに機能を追加して強化すればいい。iPhone でないと利用できないユニークな機能を追加するのだ。両方の世界のいいとこ取りで、いちばんいい方法だと思わないかい?
Fortunately, there is an alternative. You can build a web app using open source, standards-based web technologies, release it as a web app, and debug and test it under load with real users. Once you are ready to rock, you can use PhoneGap to convert your web app to a native iPhone app and submit it to the App Store. If it’s ultimately rejected, you aren’t dead in your tracks because you can still offer the web app. If it’s approved, great! You can then start adding features that enhance your web app by taking advantage of the unique hardware features available on the device. Sounds like the best of both worlds, right?
* * *
さて、あなたの心は動きませんか・・・
★→[原文を見る:Oreilly.com]
★→[原文を見る:Jonathan Stark]
Technorati Tags: CS5, HTML, iPhone App, JavaScript, Jonathan Stark, Native app, Objective-C, Programming, Web app
[…] Jonathan Stark 著「HTML、CSS、JavaScript を使って iPhone アプリを作る」 « maclalala2 おお。 […]
[…] Jonathan Stark 著「HTML、CSS、JavaScript を使って iPhone アプリを作る」 « maclalala2 […]
[…] Posted Jonathan Stark 著「HTML、CSS、JavaScript を使って <b>iPhone</b> アプリを <…. […]
[…] Jonathan Stark 著「HTML、CSS、JavaScript を使って iPhone アプリを作る」 [Jonathan Stark の本] 去年から待ちかねていた Jonathan Stark […] […]