HTMLiPhone
No money no honey and no iPhone? No worries mate, here a HTMLiPhone to play around. For the honey, look yourself;)

 
 
Free Softwaare
 
  iPhone

How to make your own app for an iPhone


This a simple example how to make a "HelloWorld" app for your iPhone. Also I will tell you how to set up a repository so that your fellows can access to your programs.

Have fun, but be patient the app is not make in 5min.




Here some links to more iPhone scripts:
Backup your iPhone
Get your data from sms.db

1) Toolchain installation - Windows:

First you need to install the toolchain. I have found a superb instruction - Toolchain Installation

Fellow could you install everything? Without any fails? Good, you have hands of gold.
I got some problems with the libraries, they wasnt all linked. But finally i got to run the HelloWorld trough all the stuff. After I got it, i eat a little bit duriaan, that calms me.

2) Create the HelloWorld:

Here also I found an instruction - UIKit Hello World

I adapted little bit the "UIKit Hello World" example. My "HelloWorld" will have a image button that will toggle when u click it.
Okay fellow lets program some lines or copy-paste it. Create a folder e.g. "DuriaanHelloWorld" and put this 4 files into it.

  • hello.m
  • HelloApplication.h
  • HelloApplication.m
  • makefile
hello.m
#import <UIKit/UIKit.h>
#import "HelloApplication.h"

int main ( int argc , char **argv )
{

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc ] init ];
     return UIApplicationMain (argc , argv , [HelloApplication class ]);
}
HelloApplication.h
#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#import <UIKit/CDStructures.h>
#import <UIKit/UIWindow.h>
#import <UIKit/UIView-Hierarchy.h>
#import <UIKit/UIHardware.h>
#import <UIKit/UIKit.h>
#import <UIKit/UIApplication.h>
#import <UIKit/UITextView.h>
#import <UIKit/UIView.h>

@interface HelloApplication : UIApplication {
    UIView       *mainView ;
    UITextView   *textView ;
}

@end
HelloApplication.m
#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#import <UIKit/CDStructures.h>
#import <UIKit/UIPushButton.h>
#import <UIKit/UIThreePartButton.h>
#import <UIKit/UINavigationBar.h>
#import <UIKit/UIWindow.h>
#import <UIKit/UIView-Hierarchy.h>
#import <UIKit/UIHardware.h>
#import <UIKit/UITable.h>
#import <UIKit/UITableCell.h>
#import <UIKit/UITableColumn.h>
#import "HelloApplication.h"

@implementation HelloApplication

/**
 Button Event method
*/
- ( void ) buttonEvent :(UIPushButton *)button
{
         if ([button isPressed ]) {
            [textView setText : @"duriaan.ch\nButton pressed!" ];
         }
        else {
            [textView setText : @"duriaan.ch\nButton released!" ];
        }
}

/**
Build the iPhone window with a button and a textview
*/
- ( void ) applicationDidFinishLaunching : (id ) unused
{
     // Create a bloody rect
    struct CGRect rect = [UIHardware fullScreenApplicationContentRect ];
    rect .origin .x = rect .origin .y = 0.0f ;
   
    // Create a view instance
    mainView = [[UIView alloc ] initWithFrame : rect ];
   
    // Create a window instance
    UIWindow *window ;
    window = [[UIWindow alloc ] initWithContentRect : rect ];
    [window orderFront : self ];
     [window makeKey : self ];
     [window _setHidden : NO ];
     [window setContentView : mainView ];
   
    // Create the textView and set some settings
    textView = [[UITextView alloc ] initWithFrame : CGRectMake ( 60.0f , 0.0f , 260.0f , 60.0f )];
     [textView setEditable :NO ];
     [textView setTextSize : 16 ];
    [textView setText : @"duriaan.ch\nHello World for iPhone" ];
    
     // Create a push button with images nd set some settings for toggle imgage on push
    UIPushButton *button =[[UIPushButton alloc ] initWithFrame : CGRectMake ( 0.0f , 0.0f , 100.0f , 60.0f )];
   
    // Settings fo ON behaviour
    NSString *onFile = [NSString stringWithFormat : @"/Applications/DuriaanHelloWorld.app/on.png" ];
    UIImage * on = [[UIImage alloc ] initWithContentsOfFile : onFile ];
    [button setImage :on forState : 1 ];
   
    // Settings fo OFF behaviour
    NSString *offFile = [NSString stringWithFormat : @"/Applications/DuriaanHelloWorld.app/off.png" ];
    UIImage * off = [[UIImage alloc ] initWithContentsOfFile : offFile ];
    [button setImage :off forState : 0 ];
   
    [button setEnabled :YES ];
    [button setDrawContentsCentered :YES ];
    [button setAutosizesToFit :YES ];
    [button setNeedsDisplay ];
    // Append Button event for toggle image
    [button addTarget :self action :@selector (buttonEvent :) forEvents : 255 ];
        

    // Append the textview and the button to view instance
    [mainView addSubview :textView ];
    [mainView addSubview :button ];
}

@end
makefile
CC = arm-apple-darwin-gcc
CFLAGS = -g -O2 -Wall
LD = $(CC)
LDFLAGS = -framework CoreFoundation -framework Foundation -framework UIKit -framework LayerKit -lobjc

all :   Hello

Hello : hello.o HelloApplication.o
    $(LD) $(LDFLAGS) -o $@ $^

%.o :    %.m
    $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

clean :
    rm -f *.o Hello
3) Compile the HelloWorld and set up the app:

Run "make" from the "cygwin" commandline.

$ make
arm-apple-darwin-gcc -c -g -O2 -Wall  hello.m -o hello.o
hello.m: In function 'main':
hello.m:7: warning: unused variable 'pool'
arm-apple-darwin-gcc -c -g -O2 -Wall  HelloApplication.m -o HelloApplication.o
arm-apple-darwin-gcc -framework CoreFoundation -framework Foundation -framework UIKit 
-framework LayerKit -lobjc -o Hello hello.o HelloApplication.o
$                                  

At this point you will see probably many fails and warning. Check all your libraries symbolic links in your iphone-filesystem-folder e.g. "\usr\local\share\iphone-filesystem\usr\lib", because after you copy your iPhone-filesystem to your PC many symbolic-links will be lost. If everything run well, you shold have now a binary file "Hello" in your folder.

Create a new folder with the name of the app e.g. "DuriaanHelloWorld.app" and move your binary file "Hello" into. Also copy the images into, "icon.png", "on.png" and "off.png".

Now we create the "Info.plist" so that your iPhone know what he should do.
Important is that the string value of the key "CFBundleExecutable" is your executable e.g "Hello".
Put the "Info.plist" also into the app folder e.g. "DuriaanHelloWorld.app".

Info.plist
<? xml version = "1.0" encoding = "UTF-8" ?>
<! DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version = "1.0" >
<dict>
    <key> CFBundleDevelopmentRegion </key>
    <string> English </string>
    <key> CFBundleExecutable </key>
    <string> Hello </string>
    <key> CFBundleIdentifier </key>
    <string> ch.duriaan.software.iphone.DuriaanHelloWorld </string>
    <key> CFBundleInfoDictionaryVersion </key>
    <string> 6.0 </string>
    <key> CFBundlePackageType </key>
    <string> APPL </string>
    <key> CFBundleSignature </key>
    <string> ???? </string>
    <key> CFBundleVersion </key>
    <string> 1.0 </string>
    <key> SBUsesNetwork </key>
    <integer> 3 </integer>
</dict>
</plist>

Your "app" folder should look like this. Be sure that all files have mode "0755"(chmod 0755 *), otherwise iPhone cant start it. The "icon.png" is the app image.

Here the images files:
icon.png on.png off.png

$ pwd
/tmp/DuriaanHelloWorld/DuriaanHelloWorld.app
$
$ chmod 0755 *
$
$ ls -la
total 48
drwxr-xr-x+ 2 duriaan duriaan        0 Jan  6 13:45 .
drwx------+ 3 duriaan duriaan        0 Jan  6 13:33 ..
-rwxr-xr-x  1 duriaan duriaan 17648 Jan  5 00:42 Hello
-rwxr-xr-x+ 1 duriaan duriaan      679 Jan  5 00:38 Info.plist
-rwxr-xr-x+ 1 duriaan duriaan     6562 Jan  4 23:11 icon.png
-rwxr-xr-x+ 1 duriaan duriaan     6973 Jan  4 23:13 off.png
-rwxr-xr-x+ 1 duriaan duriaan     7035 Jan  4 23:12 on.png
$                                  
4) Create the repository:

Now we will create the repository, so that all your fellows can dowload this nonsense example.
ZIP the "app" folder from the commandline from "cygwin", dont use some other bloody ZIP'ers, otherwise you will lose the file modes and then "halleluja". You will spend ages for find the bug.
Also run command "md5sum" for the hash value, "date +%s" for the timestamp and "ls -la" for the size of the ZIP-file. This information we need later for build the "index.xml"-file.

$ pwd
/tmp/DuriaanHelloWorld/
$
$ zip DuriaanHelloWorld.zip DuriaanHelloWorld.app/*
updating: DuriaanHelloWorld.app/Hello (deflated 82%)
updating: DuriaanHelloWorld.app/Info.plist (deflated 51%)
updating: DuriaanHelloWorld.app/icon.png (stored 0%)
updating: DuriaanHelloWorld.app/off.png (stored 0%)
updating: DuriaanHelloWorld.app/on.png (stored 0%)
$
$ls -la
drwx------+ 3 duriaan duriaan        0 Jan  6 20:14 .
drwxrwxrwt+ 8 duriaan duriaan     0 Jan  6 19:57 ..
-rw-r--r--  1 duriaan duriaan 24919 Jan  6 20:14 DuriaanHelloWorld.zip
$
$ md5sum DuriaanHelloWorld.zip
8258a2ca7b17fd4a228fefdcaf6a2164 *DuriaanHelloWorld.zip
$
$ date +%s
1199475620
$                                  

Now my friend, we set up some folders on the website. Create a folder e.g. "iphone-apps" and inside this structure:

  • /somewhere/over/the/rainbow/iphone-apps/
  • /somewhere/over/the/rainbow/iphone-apps/info/
  • /somewhere/over/the/rainbow/iphone-apps/info/info.hml
  • /somewhere/over/the/rainbow/iphone-apps/zips/
  • /somewhere/over/the/rainbow/iphone-apps/zips/DuriaanHelloWorld.zip
  • /somewhere/over/the/rainbow/iphone-apps/index.xml

In the "info"-folder put the "info.html" with some information, in HTML, about ur smelly duriaan program. In the "zip"-folder put your zipped "app" e.g "DuriaanHelloWorld.zip".
Now create a file with the name "index.xml" an bash it to the "iphone-apps"-folder. Change what you want to change it, but always be aware because some values have to be correct, otherwise u will got many exceptions and go crazy!

In the string of the keys "size", "date", "hash" you will put the above described values. Dont put any other cavy into it.

index.xml
<? xml version = "1.0" encoding = "UTF-8" ?>
<! DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" >
<plist version = "1.0" >
    <dict>
        <key> info </key>
        <dict>
            <key> name </key><string> duriaan.ch software </string>
            <key> author </key><string> V:T </string>
            <key> maintainer </key><string> duriaan.ch </string>
            <key> url </key><string> http://www.duriaan.ch/software/iphone-apps/info/info.html </string>
            <key> contact </key><string> i_love_eat@duriaan.ch </string>
            <key> category </key><string> duriaan.ch sources </string>
            <key> description </key><string> duriaan.ch repository with some HelloWorld examples... </string>
        </dict>
       
        <key> packages </key>
        <array>
            <dict>
                <key> name </key><string> DuriaanHelloWorld </string>
                <key> bundleIdentifier </key><string> ch.duriaan.software.iphone.DuriaanHelloWorld </string>
                <key> contact </key><string> i_love_eat@duriaan.ch </string>
                <key> description </key><string> DuriaanHelloWorld Example... </string>
                <key> location </key><string> http://duriaan.ch/software/iphone-apps/zips/DuriaanHelloWorld.zip </string>
                <key> size </key><string> 24919 </string>
                <key> version </key><string> 1.0 </string>
                <key> date </key><string> 1199475620 </string>
                <key> hash </key><string> 8258a2ca7b17fd4a228fefdcaf6a2164 </string>
                <key> category </key><string> Misc </string>
           
                <key> scripts </key>
                    <dict>
                        <key> install </key>
                        <array>
                            <array>
                                <string> CopyPath </string>
                                <string> DuriaanHelloWorld.app </string>
                                <string> /Applications/DuriaanHelloWorld.app </string>
                            </array>
                        </array>
                    <key> uninstall </key>
                        <array>
                            <array>
                                <string> RemovePath </string>
                                <string> /Applications/DuriaanHelloWorld.app </string>
                            </array>
                        </array>
                    </dict>
            </dict>
        </array>
    </dict>
</plist>
5) Add the source to your iPhone and lets rock it

On your iPhone click the "Installer", then choose "Sources" and add the repository:
http://www.duriaan.ch/software/iphone-apps/index.xml
You will see now a "duriaan.ch software" repository. If you look out on your office window you will probably see a watercow.

The screenshot i took with the iPhone tool "iPhone Screenshot" from "robota software", great tool better then mine.

snap_230838.jpgsnap_230842.jpg

Go to the "Install" section to the folder "Misc" or "Recent Packages", there you will find the app "DuriaanHelloWorld". Choose it and "Install" it.

snap_230909.jpgsnap_230913.jpg

Have fun and eat duriaan's...its healthy and it smells so gooood...

snap_230950.jpgsnap_230955.jpg

I think, I spent more time to make this documentation, then to program the sample;-)

Here a simple command to back up all your iPhone filesystem. "192.168.1.10" is the IP-Address of your iPhone. Execute this command on your machine.

$ 
$ ssh root@192.168.1.10 tar -c / | (cd /tmp/iPhoneBackup/; tar -x)

Here some lines to let u know how to get your awesome messages (SMS) from your iPhone.

Python sqlite3 documentation

sms_sqlite.py
#!/usr/bin/env python
import sqlite3

def print_db_content(sqlite_db, sqlite_table):
    conn = sqlite3.connect(sqlite_db)
    c = conn.cursor()
    
    c.execute('select * from %s' %(sqlite_table))
    for row in  c.fetchall():
        print row
    
    c.close()
    conn.close()
    
print print_db_content("C:\\temp\\sms.db", "message")
$ 
$ python sms_sqlite.py
(10, u'+417xxxxxxxx', 1215343096, u'What r u doing?', 2, 0, None)
(11, u'+417xxxxxxxx', 1215343163, u'Im home feeding my watercow and u?', 3, 0, None)
(12, u'+417xxxxxxxx', 1215343274, u'Im bored.Can I come to ur home?', 2, 0, None)
(13, u'+417xxxxxxxx', 1215343374, u'Come here I will make a duriaan juice for u!', 3, 0, None)
(14, u'+417xxxxxxxx', 1215343474, u'Great!!!', 2, 0, None)
(15, u'+417xxxxxxxx', 1215343574, u'See u soon...and dont forget to bring ur socks!', 3, 0, None)
None
$

If flags is set to "3" that means you wrote a message. If "2" your friend sent the message.

Here the description of the columns of sms.db:
ROWID INTEGER PRIMARY KEY AUTOINCREMENT,
address TEXT,
date INTEGER,
text TEXT,
flags INTEGER,
replace INTEGER,
svc_center TEXT


Here some more databases and the tables names:

database tables
sms.db message, sqlite_sequence
voicemail.db voicemail
call_history.db call
keychain-2.db cert, genp, inet
notes.db Note, note_bodies
calldata.db npa, npalocation, npanxx
 
Home | CopyPathToClipboard | iPhone | RSSFeeder | EasyFileEraser | ThumbnailExtracter | HTMLTable2Img | FolderTreeToClipboard | Contact us  

Copyright © 2005-2008 duriaan.ch All rights reserved.