I’ve been hacking this week and I did it on both phones!

First I’ve got Openmoko running Mono. Not sure if anyone else beat me too and already did it but it pretty much worked out of the box, after some environment variable tweaking. Hello World at the shell is alive! After I got it running, I stopped. This isn’t so much a challenge in that this runs Linux, up to par with the Maemo OS on the Nokia 770/N800/N810 and we already have decent ARM support for that. It was surprisingly uneventful.

On the iPhone side, I’ve got something that is working to some extent. I’m cheating in some evil ways to make it load so I feel weird calling this officially “running” Mono yet, but I thought it was blog worthy since I did get it to call me back with a string that contains the all to classic “hello world” (totally heart stopping moment). This is different then the earlier effort in that my way is fully within the rules of the official SDK from Apple (other one ran on jail broke phones). I have to give credit to the previous effort because if it wasn’t for that work to get it working on the jail broken version months ago, I wouldn’t have this working as well as I do now. Lots of issues still to overcome still but Mono is looking to be a really viable option for development needs on the iPhone.

It’s hard to post pics to get everyone excited because right its just me sitting in front a really cryptic terminal and debugger, but trust me, it works!

In the mean time I’m still working on my PocketWiki application. Finding bugs in the SDK but there are some interesting things you can do.

This little sniplet sets the content of a webview, and then a button on the window is wired up to execute a function in that HTML and get the result back and display it in an NSAlertView:

- (void)awakeFromNib {
	[webView loadHTMLString:
	 @"<html><head><title>Hello HTML</title>\n"
	 @"<meta name=\"viewport\" content=\"width = device-width, user-scalable = no\" />\n"
	 @"<script>\n"
	 @"function getText(){\n"
	 @"return document.testform.test.value + \"\\n\";\n"
	 @"}\n"
	 @"</script>"
	 @"</head><body>TEST <form name=\"testform\">"
	 @"<input name=\"test\" type=\"text\" value=\"example\" id=\"test\" />"
	 @"</form></body></html>"
					baseURL:nil];
}

- (IBAction)buttonPush:(UIButton *)sender {
	NSString* var = [webView stringByEvaluatingJavaScriptFromString:@"getText()"];
	if (var != nil)
	{
		UIAlertView *alert = [[UIAlertView alloc]
		    initWithTitle:@"The text box says "
			message:var // bug? they will release our string
			delegate:nil
			cancelButtonTitle:@"OK"
			otherButtonTitles:nil];
		[alert show];
		[alert release];
	}
	//[var autorelease];
}

Shameless plug: If your company wants to break into this hot market while it lasts and deploy a rich client app for the iPhone that ties into your business’s existing web services or applications so that you enrich them with features like quick auto-login (and other data stored locally on the the phone), offline capabilities, camera, and location apis, and the upcoming push services API Apple is soon to release, you can contact me through my site. :-)

Update:
I jumped the gun. What I was seeing was a EXC_BAD_ACCESS error releasing my thread and returning my callback I was expecting when it worked. I didn’t see the crash because of another bug. The memory on the iPhone can’t be executable and writable at the same time. This is a iPhone 2.0 change. iPhone Mono will only work if we get Mono full AOT (or someone brings back the Mono interpreter from the dead).

Tags: ,