2010/10/23

Web OS programming - My very first Palm Pre 2 app (that really does nothing!)

I find programming model in WebOS very intuitive and easy. I really like it and even though I have no real device to test anything, there is an emulator and I think is very complete (probably better than the first iPhone Simulator app)

These are some notes on how to create Palm Pre apps using Terminal in the Mac but this should not be different in any other Unix like OS.
There is a Eclipse Plugin that should make things easier but I don't like very much Eclipse, is kind of sluggish, I prefer Xcode or NetBeans but there are no Web OS Development official plugins for these IDEs now. So my best choice is Terminal + Coda (Coda is awesome!!).
Moreover, Coda has Terminal inside of it so no need to really open Terminal.app in the Mac.

  • Download and install the SDK and Emulator (needs Virtual Box), follow instructions from here
  • Open the terminal and do:
//Step1: create a workspace directory
$mkdir palmWorkspace
$cd palmWorkspace

//Step2: create a project with name HelloWorld
$palm-generate -p "{title:'Hello World', id:com.nacho4d.hello, version:'1.0.0'}" HelloWorld
generating new_app in /Users/nacho4d/Documents/palmWorkspace/HelloWorld

//Step3: package the project (something equivalent to building an iPhone app)
$ palm-package Helloworld
creating package com.nacho4d.hello_1.0.0_all.ipk in /Users/nacho4d/Documents/palmWorkspace

//Step4: install the packaged project in the connected device, if none then install in the Emulator *4
$palm-install com.nacho4d.hello_1.0.0_all.ipk 
installing package com.nacho4d.hello_1.0.0_all.ipk on device "emulator" {41270192eca5e9403d535ba2f9e40b4483cda4ac} tcp 50997

//Step5: start the app
$ palm-launch com.nacho4d.hello               
launching application com.nacho4d.hello on device "emulator" {41270192eca5e9403d535ba2f9e40b4483cda4ac} tcp 50997

//Step6: close your app through a command. 
$palm-install -c com.nacho4d.hello_1.0.0_all.ipk
closing application com.nacho4d.hello on device "emulator" {41270192eca5e9403d535ba2f9e40b4483cda4ac} tcp 50997 


Now, regarding...

Step 2: palm-generate [OPTION...] APP_DIR
palm-generate -p option is optional. Hence, you could do $palm-generate HelloWorld and would create an app with title: HelloWorld id:com.yourdomain.helloworld and version:1.0.0.

Step 3: palm-package [OPTION...] APP_DIR
I said this step is something like building an iPhone but I don't think you will get any errors here. everything is HTML and Javascript so, you have to validate/check your code by yourself.

Step4: palm-install [OPTION...] [PACKAGE | APP_ID]
If your are using the emulator, you must start it manually(palm-install won't start it for you) but , starting it just before running this command probably will end in something like this:

$ palm-install com.nacho4d.hello_1.0.0_all.ipk 
palm-install: no devices found
palm-install: no device found

The first message is for real devices and the second is for the emulator. It seems that the emulator is not immediately available just after starting it. So, better start it at packaging time.

Step5: palm-launch [OPTION...] [APP_ID]

Step6: you can also close the app using the Emulator by swiping your app up. (I am very new to PalmPre and I didn't knew this ;) )


If your are using Coda, then do everything inside its built-in terminal!



You can even open the your workspace directory from its terminal, So won't even need the Finder. ;)

$cd palmWorkspace/
$open . -a Coda.app
... and do as usual ;)






0 comments :