Archive for March, 2008

iPhone SDK, initial impressions

Saturday, March 8th, 2008

I have spent quite a few hours with the iPhone SDK now and must say that I am quite impressed. The experience of bringing some of my code written for Mac OS X over to the iPhone with no changes and having it just work is quite a pleasant experience. I REALLY enjoy being able to use Objective-C 2.0 synthsized properties and fast enumerators in my code (garbage collection would have been nice but hey, this is a mobile device). I maintain Tiger support for Language Aid and develop purely for Leopard in Razor and it is kind of an interesting mix of both to code for the iPhone. I am really excited to to flesh out a game I have been thinking of for the iPhone that would take advantage of a lot of its unique features.

nativearch

So the posted requirements say that this beta version of the SDK requires an Intel Mac but so far I have not run in to much trouble developing with it on my G5 (the only Intel mac in the house right now is a Core Solo mini which is already pulling duty as a source server, build server, DVR and media center). Inspecting the simulator and the xcode plugins show that they are all universal binaries. The only gotcha that I ran into is that I had to make sure that in my build settings that the “Architectures” setting is set to “Native Architecture of Build Machine” so that the binaries produced are ppc so that the simulator (I have heard a surprising number of people errantly referring to it as an emulator) can load and run them. For some reason this reset itself to i386 one time and I had to track it down to that setting.

Other small quirks that may or may not be related to me running on ppc are that it seems like every 10th click event or so on the simulator window seems to fall through and hit the window behind it. Also, for some reason the simulator is also not responding to the “Rotate” commands whereas it would correctly respond on my Intel mini. Of the example code on the developer website there are a lot of projects that will not run in the simulator due to a pragma that intentionally errors itself out if built targeting the simulator:

#if TARGET_ASPEN_SIMULATOR
#error This application cannot be run in the Aspen Simulator. Please change Active SDK to “Device” and ensure a device is connected.
#endif

The common theme of which projects will and will not run seemed to be that they all used Open GL ES. I eventually stopped to read the description before downloading the example which explicitly states as much:
Simply build the sample using Xcode and run it on the device (OpenGL ES is not supported in the simulator).

It is inevitable that I will plunk down the $99 to be able to perform remote debugging/use Instruments/use Shark with a real iPhone. However, for now while I am busy bringing up the core game engine and getting used to the new platform, the simulator is doing just fine.

Of NSServices and lsregister

Wednesday, March 5th, 2008

Services

Launch Services is one of those things that does a lot of magic for Mac OS X but is not really visible on the surface and is somewhat vague and ethereal. Launch Services is responsible among other things, for associating file types with applications, associating icons, associating system services and many other wonderful things that make your experience just work. Fortunately there is a tool to poke at the Launch Services database buried in the system at:

/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister

Most notably the -dump command basically outputs the database so that you can see exactly why a certain file type wants to be opened by which app and why certain files get their icons and association hijacked by some other random new app. The -f command will let you update the database with any new changes you have made to an application or bundle.

Some of things managed by this database are the system services that show up in the “Services” option under the application menu (these are outlined in the NSServices array of a bundle’s Info.plist). Language Aid provides one of these as an alternative to the lookup trigger and contextual menu as a way to lookup text. Unfortunately, it appears that just tickling the database with the new information about which options you want available in the menu (dictated by which plugins you have selected), is not enough to rebuild the Services menu. A reboot seems to do the trick, but it would really be nice if I could figure out what causes that menu to rebuild.

Language Aid 1.1.2 is out!

Saturday, March 1st, 2008

One of the things I hear most often while providing support for Langauge Aid is something along the lines of “I hovered my cursor over text in some program, hit the lookup trigger and it didn’t do anything/grabbed the wrong text.” This is sometimes because the application they want to grab text from does not support the Accessibility API or sometimes because what they were hovering over wasn’t really text. Thus I have added a feature in version 1.1.2 that should help alleviate confusion.

highlight

Now in Language Aid 1.1.2 if you hold down the lookup trigger for more than one second, a highlight bubble will appear containing the text that will be grabbed if you let up your lookup trigger. You can also move the cursor around while holding the lookup trigger to see the exact text that would be grabbed from any point that your mouse cursor can hover over. So now if you are unsure about what text will be sent to the plugin, simply hold down the lookup trigger and move the mouse cursor around until you find the text you want. The highlight bubble is also slightly translucent so you can see the text under it.

I have also slightly overhauled the main Language Aid website to focus more on the the three different ways that you can use Language Aid to grab text. I have added short videos that explain and demonstrate each way. Also, a quick side note on Quicktime video encoding…the “Prepare for Internet Streaming” setting is BAD. When run in my web browser I found that my videos would often play for a bit, then the video would freeze but the progress slider would keep moving. This would continue until the end of the video. If you scrubbed through the video it would seem to display fine. However, if you scrubbed to a section in the video and then pressed play, it would play for a bit and then freeze again. Strangely enough, when played through Quicktime Player this did not happen quite as much but still occasionally would occur. I found that when I turned off the internet streaming setting this behavior stopped. Also, setting my H.264 keyframes setting to “Automatic” from 24 seemed to cut my file sizes in half. I suppose the moral of the story is that it pays to deviate from the default video encoding settings.