Afternoon nap’s Blog

April 30, 2009

Giving in to get a debugger, iphone simulator – Dell mini 9n

Filed under: iphone, miscellaneous — Tags: , , — afternoonnap @ 10:56 pm

Well folks, I took the plunge. Yes, yours truly bought OS X and installed it. on a Dell Mini. Downloaded and installed XCode. Iphone SDK.

IT IS SWEET. I won’t lie, had there been a way to use the iphone simulator using the winchain toolkit or even get a debugger on windows for objc + apple libs, I would have done it. But there really isnt s’far as I could figre it out.

So here’s what I did

-dell.com , bought me a real basic unit mini 9

-bought RAM, SSD upgrade (going to), external keyboard mouse 2nd hand or from third party sides (dirt cheap)

-bought student edition OS X (i study)

-got an ISO and burned the DellEFI Bootloader

-vga cable for external monitor

Now, I have a fully functional mini-dell mac, everything works including sleep, XCode runs well, iphone simulator is excellent, and i am set to learn without impediments. Total cost.. approximately 400, but including upgrades.

My goal was to focus on code development/debug/deploy/and eventual release into appstore, just was not able to get that fully going with the toolchain. especially the debug and deploy portion. Meanwhile I updated my iphone firmware to 2.2.1 (by no choice of mine, I screwed it up by doing something so had to upgrade).

I will continue to post things as I learn how to use XCode, I would still like to learn with other newbies out there.

March 13, 2009

Question to readers regarding gcc make

Filed under: Uncategorized — Tags: , , — afternoonnap @ 4:06 am

I will be removing this post but:

How can i get the compiler to print out path to the libs its using during compiling process (including headers it needs).. more verbose the better?

For those of us who cannot compile on the iphone 2.0 toolchain on the iphone itself, this would be the nail in the coffin to this issue… please comment if you have suggestions.. i have a few examples of stuff i tried out id like to put up but not everyone is able to compile yet! ridiculous & id like to try and help fix this!

March 12, 2009

“Help! ________ doesnt work for me!”

Filed under: iphone — Tags: , , , — afternoonnap @ 4:50 am

Theres a few recurring issues people are running into. I’ll summarize a few here and whats worked for me. Please email me more to add. Even if we dont know how to solve it (yet):

COMPILING / RUN ISSUES

- arm-apple-darwin9-gcc.exe doesnt work on the iphone winchain build :   requires repository svn download and rebuild using OS 2.0 headers, instructions still to be posted when i get some good amount of time or someone volunteers…

- code here does not build : probably missing some includes or frameworks. Solution? Look at whats failing, usually can be solved by pulling includes and frameworks from cygwin toolchain directory. Some people still cant compile , getting missing interface errors. we are still trying to figure out whats different between my install and theirs. stay posted.

-code here does not build even after including appropriate libraries: Are you compiling code meant for iphone OS less than 2.0 ? I found this out the hard way – graphics examples wouldnt compile. Solution? you need OS 2.0 + specific code, a lot of stuff from < 2.0 doesnt compile anymore.

-code does not run even after OK build: did you chmod 775 your Info and binary? did you ldid -S your binary? Did you point your Info to your binarys executable name? Is your binary compiled without referencing stuff that your OS 2.0 doesnt support? Solution: all of the above

-code still doesnt run!: so youve done all the obvious, your code still kicks off and after the initial splash screen, just dies? Solution? time to debug, throw in a few NSLog statements, recompile and run from within putty, see where the failure is occurring. This is how I figured out that LKLayer (LayerKit framework) wasnt cooperating. From there I discovered apples newer OS 2.0 build doesnt even have LayerKit (which you’ll see a lot of examples on the web use … meaning they were build pre-2.0 ).

-some code project i downloaded from the web built on xcode along with NIBs wont run :  seems like gotta convert from original interface mapping file into an XCode specific  NIB and throw into your project once you compile – i got a few missing interface problems due to this one to. Solution? Until figure out how to get the NIB converted , stay clear of projects that use them?

TOOLCHAIN ISSUES:

I think previous posts are sufficient.

February 22, 2009

setting up iphone toolchain on the iphone,compiling and running an app on iphone thereafter

Filed under: iphone — Tags: , — afternoonnap @ 4:57 pm

1) Open up Cydia

1.5) These are the sources I’ve added, you may or may not need them; i don’t think adding them will hurt (tx Jeff for suggestion):

-Telesphoreo Tangelo, http://apt.saurik.com
-ZodTTD, http://www.zodttd.com/repo/cydia
-Ste Packaging, http://repo.smxy.org/cydia/apt
-ModMyi.com, http://apt.modmyi.com/
-iSPazio, http://cydia.ispazio.net/
-BigBoss & Planet-iPhones, http://apt.bigboss.us.com/repofiles/cydia
-apt9.yellowsn0w.com, http://apt9.yellowsn0w.com
-Hackulo.us, http://cydia.hackulo.us
-www.iphone.org.hk , http://www.iphone.org.hk/apt (seems to be at some sort of limit )

2) search for  following items, download & install:

-”GNU C Compiler”
-”iphone toolchain”
-”Make” ( browse till you see the one from Telesphoreo )
-”Link Identity Editor” this is what we refer to as LDID in other posts
-Respring (find a suitable one)

5) go to the Makefile post to get full app kit (make file for the iphone, sample program that will compile)

6) Extract the code folder and push it onto your iphone using WinSCP or putty

7) Putty into your iphone, browse into the code folder

8) type in make -f [makefile name]

9) if you see no errors, good job

10) there should be a new “.app” folder now that the compilation process created. cd into it through putty

11) sign your binary , type in “ldid -s  [binary name]

11.5) in your .app folder, do an “ls -larth” to look at the execution privileges of the binary and the Info.plist – modify with “chmod 775 {filename}” if necessary

12) Winscp or putty for this step – move the .app folder into your root /Applications directory (i think mobile/Applications might work too but I havent tried this)

13) respring your iphone

14) you should now have an icon on springboard, try it out

I think this post along with the local toolchain  setup post should be sufficient in getting anyone up and running (although the local toolchain setup is sadly lacking the follow since I lost my cygwin install after i posted that entry).

February 19, 2009

Makefiles – a collection

Filed under: iphone — Tags: — afternoonnap @ 7:06 pm

A collection of projects/makefiles that work, you can unzip folder to location and compile through putty. If you have any that are useful feel free to let me know Ill add them to this section.

compile location:   *** Directly on iphone ***

what it is: single helloworld.m file, displays background image that is orientation sensitive;  how to use it: rename extension to .zip, expand into a folder, copy folder onto the iphone, and run command   make -f Makefile.iphone ; DOWNLOAD LINK : helloworldzip

Recompiling the darwin9 compiler for x86 platform (to use through cygwin)

Filed under: Uncategorized — afternoonnap @ 5:01 pm

coming soon

<update> unfortunately ive gotten real tied up past few weeks, i apologize if you were waiting on this one. anyone care to help out, i just havent had the couple of hours i need to recreate this and post.

January 30, 2009

Updated Theme

Filed under: miscellaneous — Tags: — afternoonnap @ 6:07 am

Finally found a theme that isnt retarded with tons of empty space on either side – just all content :)

January 26, 2009

A few steps back – picking up cocoa

Filed under: iphone — Tags: , — afternoonnap @ 6:34 pm

After some investigation with OpenGLES and trying to get it to compile, Ive come to the conclusion that largely in and of itself constructing an opengl program to run on the iphone is not what i should be doing.  Focusing entirely on OGL will mean that I wil be skipping important lessons in building solid objective c code, not to mention learning how to properly utilize frameworks like Cocoa and Core graphics, as well as the objc method of memory management.  My initial goal had been to circumvent objC entirely and code utilizing C++ or C, include OGLES libs, and compile.

My new focus will be running through a series of ObjC lessons, learning the cocoa framework, and integrating with core graphics and finally with opengl. This way, the learning curve will be incremental and useful.

If you’d like to see sample code as I move along tutorials that are available, please let me know I can certainly oblige.

January 11, 2009

figured out the compile error

Filed under: iphone — Tags: , , , — afternoonnap @ 9:10 am

i basically had to manually update the toolchain installed on the iphone fs to be able to try to compile OpenGL ES 1.1 (which is whats installed on the iphone) C files. Ive decided to compile on the hardware itself.

That being said, the goals are now as follows (Ill update this post as i go along):

1) a c file that implements a triangle render using openGLES

2) a makefile that successfully compiles

3) demonstrated execution.

I am trying to work on 1) by converting openGL example to openGLES 1.1.

January 5, 2009

taking a break, need to figure out this compile error on local toolchain build

Filed under: iphone — afternoonnap @ 3:35 am

configure: error: cannot execute: /usr/local/bin/arm-apple-darwin9-ld: check –with-ld or env. var. DEFAULT_LINKER

Meanwhile, ive been thinking about this facebook app i myself would use – a tool for people who want to beat a habit.  how difficult is it to build a FB app?

January 3, 2009

compiling a GUI app that uses the COCOA framework (see Makefile post for complete example)

Filed under: iphone — Tags: , , , , — afternoonnap @ 8:16 am

Alright so this is where things are starting to fall apart for me – i run into all kinds of issues compiling on cygwin. I’ll get into why later.. for now my recourse is to try compiling directly on the phone [Edit : If you follow instructions on Jonathan A. Zdziarski's iPhone Open Application Development book, the compilation can be done through cygwin.. but to retain homogeniety I will continue describing what I have already done]

… i will be using the makefile located in this simple GUI window sample to fix the ones built for local toolchain before compiling on the phone:

http://a27dev.com/objc/SimpleWindowApp.zip

So, from the shell prompt, i type a simple make and it picks up the makefile (I wonder is the Makefile always the same name is that how it knows what to pick up?) and away it goes..

A folder called HelloWorld.app is created with the springboard icon graphic, the plist file, and of course our compiled object. This folder has to be placed to the root app directory:

/Applications/

Then, restart iphone or … download Respring from Cydia and respring phone.

The new icon shows up on the dashboard.. open it.. and there we are… a text box!!

Next step – getting the cocoa compilation process to work locally!

setting up iphone toolchain locally on windows using cygwin etc

Filed under: iphone — Tags: , , — afternoonnap @ 5:48 am

** Note – these PDFs from more experienced people usually seem to refer to pre-iphone OS 2.0 toolchains – for example LayerKit no longer exists in current apple sdk but you can see its mentioned in the docs. Just be aware of this & that you may need to recode examples to get them to work once you deploy to iphone **

Alright this is where I turn it over to the master. Just read this document and … well the rest is very self explanatory! I just followed it and I’ll put down what i did just in case it helps too but…first… read :

os-eclipse-iphone-cdt-pdf

Steps I followed:

1) installed cygwin locally on vista using all the options especially compilers , sudo,etc.. (read PDF for details)

2) Downloaded iphone toolchain from PDF authors website http://www.pjtrix.com/iphone/articles/eclipse-cdt/iphone-2.0-toolchain.tgz

3) Downloaded apple IPSW http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone/061-4956.20080710.V50OI/iPhone1,1_2.0_5A347_Restore.ipsw

4) copy iphone toolchain stuff into your cygwin directory per PDF

5) unzip IPSW, pull out a certain DMG image file out of it (see PDF)

6) decrypt the DMG image file using something from the iphone toolchain (see PDF)

7) use Transmac or UltraISO to load the DMG

8) copy certain files from the loaded cd image to the iphone toolchain cygwin directory (see PDF)

9) the fun part… start compiling in cygwin using the make-toolchain file thats provided (this will replicate our iphone compilers locally i guess?)

10) I had a few hiccups. Notably, with the last gcc part of the makefile.
I had to locate the [configure] section and update the path to gxx-include to the following in the makefile:

with-gxx-include-dir=/usr/local/arm-apple-darwin/include/c++/4.0.0

11) finally, i recompiled HelloWorld, except this time using the apple compilers locally (im pasting what is in the PDF to show the updated compilers makefile for HelloWorld points to):


CC=/usr/local/bin/arm-apple-darwin9-gcc
CXX=/usr/local/bin/arm-apple-darwin9-g++

Then, I Win SCP’d the HelloWorld binary into the /var/root/ directory on the iphone, chmod’ed  to give it permissions, and applied LDID to give the binary a bogus signature.

Then, I ran the code and got the same output as before…

Hello, world!

…except this time I had done coding and compiling locally on a vista machine :)

_________________

Theres another “setup” doc many pages refer to  (Lucas Newman) that I had a hard time finding on the web (dead link on his site or smething like that).  Anyways, I found it today, im mirroring it here just in case its useful for anyone:

lucasnewman_nativeapp

———————————— IF YOU HAVE LINKER ISSUES ————————–

Try following post from Michael, seemed to work for him:

The problem with the linker is that the new linker is built OK (in the cctools-iphone build) but it’s never copied to /usr/local/bin. This is because of the silly $SUDO variable that already caused a bunch of problems. It’s not OK to make $SUDO just echo the command in cygwin, the sudo’d commands still have to run, they just don’t require sudo on cygwin! After the cctools-iphone build the next sudo’d command is “make install”. That’s a pretty important step, which includes installing the newly built linker etc to /usr/local/bin.

So, instead of having:

export SUDO=’echo “”;’

change that to:

export SUDO=””

That will ensure all the sudo’d commands still run, even though they don’t require sudo on cygwin.

That’s huge step! But there’s one more hurdle if you’re using cygwin on Windows: you’ll probably get the following error:

/usr/local/bin/arm-apple-darwin9-ld: /usr/local/iphone-sysroot/usr/lib/libc.dylib truncated or malformed object (mach header extends past the end of the file)
collect2: ld returned 1 exit status

This happens because when you extract the files you need from the iPhone firmware DMG, the symbolic links are not preserved (at least they aren’t if you use Transmac). This means that libc.dylib, which should be pointing to libSystem.dylib, which in turn should be pointing to libSystem.B.dylib, is just a text file with the name of the linked file. The solution is to re-create the symlinks in your /home//iphone-2.0-toolchain/iphone-fs/usr/lib directory. I found a handy little script which automates this:

find -size -200c -type f | gawk ‘{p = “”; s = split($0, sp, “/”); for (i = 1; i < s; i++) p = p (p?”/”:””) sp[i]; b = sp[s]; getline a < $0; if (match(a, /^[a-zA-Z0-9_\-\.]*$/)) if(system(”if [ -e " p "/" a " ]; then exit 66; fi”)==66) system(”cd ” p “; rm ” b “; ln -s ” a ” ” b)}’

Run this in the /home//iphone-2.0-toolchain/iphone-fs/usr/lib directory and it should fix all the important symlinks. It doesn’t fix them all and I couldn’t be bothered to debug the command but it fixes the important ones.

Nice, we’re inside, now what?

Filed under: iphone — Tags: , , — afternoonnap @ 5:27 am

Well surprisingly given how lazy I am I still found myself reaching for the Putty button on the iPhoneTunnel suite… and behold there was my login into my phone! Incidentally, in case you missed it elsewhere on the web, the default login / pwd is root / alpine

I browsed around a bit inside the phone, it is essentially an osx install which was cool cos I couldnt afford a mac machine before :) . A few of the things i explored

- the storage structure of itunes songs and the database file used to maintain it

-where applications get installed to and how to manually install apps

-how to remove apps

etc. im sure you’ll find plenty to get you going.

Eventually I wondered about compilers that come with the phone…after all its linux right? Well no surprise there, there’s a gcc compiler you can use to compile rudimentary code right on the phone! So I went through the obligatory Hello World stuff, compiled with gcc, but the damn thing wouldnt run! Each time i would execute the binary in bash, i would get a msg saying that the process was killed! Hmm whats going on??

Turns out the OS requires a signature on the binary otherwise it will kill anything that executes…fair enough… head over to cydia again.. and grab LDID utility. Sure enough, this lets you sign any executable so that it doesnt get killed when you try to run it on the iphone. so i did the following in bash on the phone:

~ root# ldid -S HelloWorld
~ root# ./HelloWorld

Hello, world!

Awesome! … or is it?

Itd be way more awesome if we could do all our coding and building right from a desktop IDE using apple’s compiler, and not worry about copying into the iphone building there and testing there….

jailbroken phone, how to get inside?

Filed under: iphone — afternoonnap @ 5:13 am

Well first thing I did was … look for a way to connect to the phone without itunes.  I didnt realize how extensively i could connect, but after some reading turns out that you can…

- open an SSH terminal into your phone!

-launch a secure SCP GUI tool to browse folders and transfer files to and from the phone!

Sure I was curious.  So how to connect to the phone using the white USB cable they provide? Turns out, not too bad:

1) through Cydia search for “SSH”. Once you find it, install. Then enable SSH on your phone using BossPrefs utility. If you cant see this utility download from Cydia.

1) search for and install iPHone Tunnel Suite 2.6 Beta. The software is in italian, so you can’t miss it.Incidentally,  the one I use that works on vista looks like this ( pssst! here it is if you cant find it… just download and rename extension to EXE its_setupexe )

Iphonetunnel beta 2.6

Iphonetunnel beta 2.6

Incidentally…this version below is floating around on the net a lot.. and it never worked for me:

other iphone tunnel suite on the web

other iphone tunnel suite on the web

so if  you’ve got this second tunnel suite & doesnt work for you … try to find the one that looks like the first screenshot i posted maybe that will do it for you.

2)

That’s it! Just launch the suite have your phone plugged in and turned on, click on the “iPhone Tunnel” button, and then click on either Putty or Win SCP . one steaming plate of iPhone guts served!

iphone 3g – purchase and breaking

Filed under: iphone — Tags: , , — afternoonnap @ 2:16 am

I recently bought an iphone 3g unit, after a friend of mine had been using his first generation one for almost a year. Seeing the convenience of the hardware and the well thought out design of the software on his first gen phone, i was finally convinced to bite the bullet when the lower priced 3g model game out.

i kind of want to chronicle my experience jailbreaking and what i have been will be upto with my phone, especially since it took me a while to research the web to find the stuff that worked for me. I wont be writing about anything i havent tried, and also…. as an aside… im a little slow researching on the web and so… im writing this for my friends out there who might be slow like me :)

On to the first step. Jailbreaking. Do you want to do it? Is it legal? Does it void apples warranty? wrong blog. this is just a place for information and knowledge sharing.

The actual jailbreaking process is almost easy as 1 , 2 , 3:

1)  dwnload and install winpwn & read the instructions

http://www.winpwn.com/index.php/Main_Page

you may need the restore firmware image..mine is http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iPhone/061-5241.20080818.t5Fv3/iPhone1,2_2.0.2_5C1_Restore.ipsw

2) master the tricky timing to get your phone into DFU mode on a reset

3) click some buttons on the winpwn program and sit there patiently

DONE!

Seeing how easy this is… it should encourage those ppl who are hesitant to give jailbreaking a try.

next… what i did after jailbreaking…

ps if you think this snippet can be more helpful with additional details please leave me a comment i’ll edit it if i can. also, do you know where i can store these files on the web long term in case the links stop working?

Blog at WordPress.com.