Tuesday, January 10, 2012

Objective-C

What have I been doing since day 1 of block leave?
Trying to experiment with coding for iOS5 notification center.

Few days ago, an author with the name of Shades published SimpleDate for Notification Center. I installed it and yes, it's exactly what I wanted before (as opposed to ClockCenter) BUT with a digital clock like the lockscreen.


Realising that it is open source from github, I decided to work on it by experimenting with Obj-C.

I am glad I had Hackintosh installed on my PC. The following is what I did. Basically, to record a note of what I have done to accomplish it.
Updating Mac OSX Lion
1. Boot to Hackintosh
2. Update Mac OSX Lion 10.7 to 10.7.2 and installed MultiBeast
3. Sound wasn't working
4. Removed HDAEnabler*.kext, ALC8xxx.kext remained
5. Reboot, sound returned (no more sound lag too!)
After updating to 10.7.2, I was then able to install Xcode 4.3 with iOS5.1 SDK (I didn't realised it until I tried to experiment with it on VMware Leopard 10.6). This installs the make bin file too, required to build the .deb from source code.

Then I Googled around, looking for tutorials on how to create a notification center template file to code. First I found is this. The original website is dead so I had to open up the cached version. I followed the tutorial, I was able to get Theos installed fine and then I ran the nic.pl, hell it didn't work.

When I tried to create the notification center template which is based from this. All I get is a package folder with Theos alias. No .m file or any files that has the template. I kept trying but to no avail. Then I redownloaded Theos without getting the notification center nic file and it works. I don't know how it affect but it stayed that way until now.

I gave up as I am unable to find a solution and so I went another way. I downloaded the source code of SimpleDate and immediately build it by using make package. It didn't work. It tells me I need dpkg-deb but I already have it by following the tutorial. So I looked for solution which is MacPort. I downloaded MacPort but didn't know what it does and how it works. Then I came across this website, who gave a really clear-cut tutorial on how to get started on Theos. Also, that's where MacPort came in I guess.

Everything works pretty after - make package as it actually builds the .deb file and I was elated.
Setting Up Compiler and Environment
1. Install Xcode 4.3 w/ iOS5.1 SDK
2. Followed brandontreb.com guide to setup Theos and other tools
3. Ran make package on Shades' SimpleDate source code
4. .deb file compiled
5. Compiler ready
I had ClockCenter source code and SimpleDate source code side by side. Those 2 are the same because Shades stated that he ripped it from ClockCenter. With C++ and C knowledge, I slightly understood Obj-C. With all the initialization and variables, it gave me a nostalgia feeling.

I basically played around to add a digital clock to the SimpleDate Shades created. I managed to do so and the end result is a date with a clock as a compact notification center widget. Oh, the clock auto-updates too by using the NSTimer class.