Chris & Computers

Tips, tricks, muses and other computer related scibblings. Mostly for myself, maybe useful to others.

Feb 15

UI development for iOS devices is not easy

I have been using Titanium for building (wordpoke), some of the biggest areas of frustration and lost time has been the work with the UI look and feel.

Things which instantly come to mind:

  • Fiddly
  • cumbersome
  • Leads to new problems
  • Over a year long problem of inserting into the front of a table
  • Hiding default borders
  • More than X elements in a table row causing the app to grind to a halt when you have more than 100 rows.
  • When iOS is updated, things may not instantly work (this in itself could be a blog post)

Since then I have looked at Interface builder from Apple and have instantly fell in love with the notion of drag n drop, stretch or shrink, see the design on the fly, the list goes on.

I have yet to dive into the actual iOS development in objective-c, I am keen.

But

This morning via HackerNews I find myself wondering if this will end up being a case of the grass is greener on the other side.

My current take away from the above is, we have been spoilt rotten with the freedom of expression handed to us via html and css.

it would appear the addition of moving parts and sexy animations, not something we are used to seeing over the years in html. The barrier to a greater freedom of expression has been raised and coding for it is harder and more finicky.

Whenever I hit a bug in the UI I have a dreaded feeling of “tweaking the CSS to make IE work” and “this is going to take an unknown amount of time to fixed”, this last part can really be soul sapping.

A final thought

Today when I work with html+css I do it via the code as I have long since learnt it is the faster and easier way.

  • “edit”,
  • “save”,
  • “refresh”,
  • “repeat”.

Yet to do that in “xcode” or “titanium” the “build process” is just a little to slow compared to the beloved “refresh”.

Search

  • titanium insertRowBefore

Links


Jan 31

Jan 23

Take a snapshot and restore your database in titanium

Working with your database in titanium

“This assumes you are working on a mac osx.”

  • Aim
  • Find
  • Copy
  • Restore
  • Explore
  • Conclusion

Aim

  • To create a snapshot of your working “.sqlite” database.
  • Allow for easily restore your database whilst developing your app with Titanium.
  • Understand how to view the contents of the file.

Find

Locate your database.

find ~/Library/Application\ Support/iPhone\ Simulator/*/Applications/* -name "*.sql"

If you have multiple folders and your willing to start with a blank database you can clean them all up with.

find ~/Library/Application\ Support/iPhone\ Simulator/*/Applications/* -maxdepth 1 -type d -prune | xargs -I{} rm -rfv {}

(I wrote about a clean build before)

Now with a clean directory. Compile your app.

Run the first command again.

find ~/Library/Application\ Support/iPhone\ Simulator/*/Applications/* -name "*.sql"

This time only one directory will appear.

The result:

/Users/[USER_NAME]/Library/Application Support/iPhone Simulator/5.0/Applications/[APP_ID]/Library/Private Documents/[NAME_OF_DB].sql
  • [USER_NAME] Your username
  • [APP_ID] The Id, I believe its created by Xcode. Yet to figure out where, Titanium stores it locally.
  • [NAME_OF_DB] The name of your working “.sqlite” database, you would have set this in your code.

Copy

Simply copy the path, best use ‘”’ so that it accepts the spacing as is without backspacing.

cd [PROJECT]/database_backup/
cp "/Users/[USER_NAME]/Library/Application Support/iPhone Simulator/5.0/Applications/[APP_ID]/Library/Private Documents/[NAME_OF_DB].sql" .

Restore

cd [PROJECT]/database_backup/
cp [NAME_OF_DB].sql "/Users/[USER_NAME]/Library/Application Support/iPhone Simulator/5.0/Applications/[APP_ID]/Library/Private Documents/"

- Exit your app. - copy the sqlite database back. - Run you app.

Examine

The file is in “.sqlite” format which means you can explore it.

cd [PROJECT]/database_backup/
echo ".dump" | sqlite3 [NAME_OF_DB].sql

This will give you the raw sql lines that are needed to build / copy / recreate your sqlite file.

If you use:

sqlite3 [NAME_OF_DB].sql

Now you can test your sql queries, tweaking them and then fixing them in your code.

Conclusion

It really does speed up productivity and development of your app. This article is due to the knowledge gleamed and time saved whilst working thru an issue in “wordpoke” my Titanium built iphone app.

Once the above was figured out, “Issue 14” became a lot easier to debug as I was able to focus just on the code, not the constant recreation of data to test if the new code was working as expected.


Oct 16
“Go to bed earlier — the Internet will be fine without you.” http://zenhabits.net/tired/

Oct 13

Headless vmware on mac

Running vmware headless on a mac.

Read the help file.

cd /Library/Application Support/VMware Fusion
./vmrun --help

Example format for starting.

./vmrun -T ws start PATH_TO_FILE nogui

PATH_TO_FILE ends with “.vmx”.

Notes


Aug 2

How to clean build for Titanium Studio

In this post I will explain how to Clean all builds when working with Titanium Studio via the command line. As I have been only working to date with iphone specific, mobile apps. It should be noted this possibly wont work so well for clean builds on android, nor for desktop.


Clean build Titanium Mobile Projects

A warning.

  • This is very much a hammer approach, it removes all build projects. Not one.
  • This was created on a Mac.
  • This I am sure will ONLY work for iphone development.
  • You will delete all builds.
  • Understand the commands before you run them. If you delete code that is not backed up somewhere. That is your fault!

Follow the steps:

Lookup

find ~/Library/Application\ Support/iPhone\ Simulator/*/Applications/* -maxdepth 1 -type d -prune

If it looks good procced, if your nervous, cp the whole lot somewhere so you can put them back.

Lookup + delete

find ~/Library/Application\ Support/iPhone\ Simulator/*/Applications/* -maxdepth 1 -type d -prune | xargs -I{} rm -rfv {}

*Copy the whole line as the theme cuts off the last little bit

Clean the build for the site you want to rebuild

Now we clean within our projects.

cd INTO_YOUR_PROJECT
rm -rf build/
mkdir -p build/iphone/

I added the “mkdir” part, as the first time I did a rebuild, it complained it was unable to find the tiapp.xml, yet when I hit “run” again, it just worked, so I concluded it was missing the directory.


Unanswered Question

How does the magic iphone number get displayed.

In the “Lookup” there were magic iphone numbers created, as hash of sorts. I searched my projects and couldnt find reference to them other than in the directory. Im guessing its an apple thing.

Equally, when you clean build, you will see you get a new id, so I think the hash involves the timestamp.


Page 1 of 7