Tuesday, June 23, 2009

Xcode 3.1.3

With the new OS installed on the iPhone, Xcode complains it needs an update. So it updated to 3.1.3.
Again, I applied the modifications to skip provisioning profile.
In terminal, type open /Developer/Platforms/iPhoneOS.platform/Info.plist (opens with Property List Editor)
Under defaultProperties add/edit rows:
This works however only with Xcode for iPhone OS 2.x.
But you can replace the iPhoneRemoteDevice executable with one one from the older Xcode.
After that, Xcode initially crashed and disconnected the cable and removed an invalid entry in the Organizer. I get some internal errors but it can be skipped by holding the return key.
I also had a problem with my project. product-pkg-utility reported that CFBundleIdentifier cannot have illegal characters (e.g. underscore).
Anyways, I can debug again.

Update: Copying the whole iPhoneRemoteDevice.xcodeplugin directory seems to work now too.
Update2: Still seems to crash, although after "Reset and relaunch" it does not crash. Weird...
Whoa... starting "/Developer/Applications/Xcode.app/Contents/MacOS/Xcode &" from Terminal seems to work in any case.

Other links: here, here here and here

Monday, June 22, 2009

iPhone OS upgrade to 3.0

Taking my chances to upgrade to the latest OS version 3.0 for iPhone.
So, first needed to backup some things: AptBackup, SpringBack and finally, a backup with iTunes.
Then create a custom ipsw with Pwnagetool. To install this ipsw, I put the iPhone into recovery mode (did not need the DFU mode, since it was already hacked) by holding both buttons on the iPhone and release the sleep button when screen goes black. Installation went fine, but...

AptBackup icon was hidden because I used the Categories app. No sweat on that, but after unhiding, AptBackup failed on me since it wasn't tested with 3.0 yet.
Solution: Installed OpenSSH and APT again and ran the following command:
for p in `cut -f 1 /User/Library/Preferences/aptbackup_dpkg-packages.txt`; do apt-get -y --force-yes install $p; done
Any packages not for 3.0 won't be installed (like mobileinstallation patch), so you need to find a newer version for them.

I seemed to have lost most settings of Cydia apps since iTunes only backs up managed settings. This includes categories, spbk files, whatever. The only items in /User where Applications, Documents, Library and Media.
So next time, I'll copy the other items manually. Also /Library/Themes for custom themes.
Tip: Get Macfusion/FUSE to mount the iPhone volume on your Mac. Or use Cyberduck.

Replace yellown0w with ultrasn0w if you updated the baseband firmware (Pwnagetool does that by default btw!). At the time of me writing it wasn't released yet though... oops.

Friday, June 19, 2009

UIProgressView custom draw method

Code snippet of a UIProgressView subclass that implements custom draw method.
This example uses four images for the left side, right side and ten sections that can be either on/off or partially filled.
My images included edge and shadow and named: pb_left.png (9x32), pb_right.png (9x32), pb_on.png (28x32). pb_off.png (28x32)

- (void)awakeFromNib
[self setBackgroundColor:[UIColor clearColor]];

// allow non-clear background color in Interface Builder, but do not draw it
- (BOOL)getClearsContextBeforeDrawing
return NO;

// draw left and right edge of progress bar with filled sections between
- (void)drawRect:(CGRect)rect
const int numParts = 10;
UIImage *pb_left = [UIImage imageNamed:@"pb_left.png"]; // "["
UIImage *pb_right = [UIImage imageNamed:@"pb_right.png"]; // "]"
UIImage *pb_on = [UIImage imageNamed:@"pb_on.png"]; // "X"
UIImage *pb_off = [UIImage imageNamed:@"pb_off.png"]; // " "
CGPoint p = {0,0};
[pb_left drawAtPoint:p];
p.x = pb_left.size.width;
int q = (int)(self.progress * numParts);
for (int i=0; i<numParts; i++)
if (i == q) // partial on/off section. works with semi-transparent images too
float w = truncf(pb_on.size.width * fmodf(self.progress * numParts, 1.0f));
[pb_on drawInRect:CGRectMake(p.x, p.y, w, pb_on.size.height)];
[pb_off drawInRect:CGRectMake(p.x + w, p.y, pb_on.size.width - w, pb_on.size.height)];
else if (i < q)
[pb_on drawAtPoint:p];
else // (i > q)
[pb_off drawAtPoint:p];
p.x += pb_on.size.width;
[pb_right drawAtPoint:p];

Wednesday, June 17, 2009

Semi-transparent overlay for UIButton subclass

A little snippet for subclassed UIButton that adds an UIImageView overlay.
You can then animate the alpha property.
- (void)awakeFromNib
UIImage *img = [self imageForState:UIControlStateSelected];
overlayImage = [[UIImageView alloc] initWithImage:img];
overlayImage.alpha = 0.0f;
[self addSubview:overlayImage];
// [self addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchDown];
// you could call custom highlight handler

- (void)setHighlightedByAlpha:(BOOL)highlighted
[UIView beginAnimations:nil context:@"hmm"];
[UIView setAnimationCurve: UIViewAnimationCurveLinear];
[UIView setAnimationDuration:0.2f];
overlayImage.alpha = highlighted ? 1.0f : 0.0f;
[UIView commitAnimations];