Category Archives: Mac

New open source iOS search project SearchTouch

I just released the first version of SearchTouch, hosted on Github at https://github.com/spoogle/SearchTouch. This is a search engine written in Objective C which compiles and runs on Mac OS X or iOS. It is designed to allow searches to be efficiently carried out on a device.

The code builds an index for a document set consisting of an inverted index for each word in a document set. The index can be stored on the device, and can be efficiently searched to produce a ranked list of every document which contains all of any given set of search terms.

There is a strict separation between the search and indexing code, and the data structures used to store indexes. This separation is mainly achieved by defining the Index class as a class cluster, although a prototcol is also used.

The main storage backend uses Core Data. There is a second back end which is purely in memory using CFTrees.

Building Wings3d on Snow Leopard

Wings3d is a surprisingly excellent 3d modeling package, written in Erlang. I have been playing with it for a few weeks, using a prebuilt .dmg. I now need to be able to build from source so I can tinker.

I hit some rocks following the build instructions on the wings3d site.

First problem: the build of ESDL which the ESDL website claims is the latest is esdl-0.94.0615. This is outdated and not compatible with current Wings3d source code – there seem to be big differences in the OpenGL libraries. Get the actual latest version instead from ESDL [sourceforge]. I got 1.0.1 and that seems to work.

After building ESDL, ESDL_PATH needs to be set correctly to compile Wings3d. I achieved that with:

export ESDL_PATH=/usr/local/lib/erlang/lib/esdl-1.0.1

Another problem with ESDL – somehow, the library files had been installed with the wrong permissions: they were owned by root and had permissions -rwx——– and so could not be read by erlang. I fixed the permissions.

Final ESDL problem – when I had built Wings3d and started it from the command line, I got an error:

Driver failed: dlopen(/usr/local/lib/erlang/lib/esdl-1.0.1/priv/sdl_driver.so, 2): no suitable image found. Did find:
/usr/local/lib/erlang/lib/esdl-1.0.1/priv/sdl_driver.so: mach-o, but wrong architecture

After some digging, I found that:

% file /usr/local/lib/erlang/lib/esdl-1.0.1/priv/sdl_driver.so
/usr/local/lib/erlang/lib/esdl-1.0.1/priv/sdl_driver.so: Mach-O 64-bit bundle x86_64

but

% file `which erlc`
/usr/local/bin/erlc: Mach-O executable i386

I added ‘-arch i386′ to the LDFLAGS and CFLAGS in the Makefile in the c_src directory of the ESDL sources and got an i386 .so library out as needed.

Another problem is that the Mac specific Makefiles and the XCode project needed to build a .dmg specify MacOS 10.4. I am running 10.6.6 and do not have the 10.4 frameworks installed on this machine, so to build I needed to specify 10.6 or latest versions of the frameworks. This was achieved by deleting -isysroot /Developer/SDKs/MacOSX10.4u.sdk where it appears in various Makefiles, and editing the XCode project in macosx/Wings3d.xcodeproj/ to change the target to 10.6 or latest from 10.4.

That was enough to get the build to work, and to yield a .dmg containing an application bundle to install.

My first piece of fiddling has been to allow a mousepress while holding down the CMD modifier to fake a right button click if a single button mouse is being used. I changed the first clause of handle_event_0 in wings.erl to this:

handle_event_0(#mousebutton{button=But,mod=Mod}=Ev, St)
   when But == 1, Mod band ?META_BITS =/= 0 ->
   %% Define CMD-mouse as right mouse button if only 1 mouse button
   case wings_pref:get_value(num_buttons) of
      1 -> ModNoMeta = Mod bxor ?META_BITS,
         handle_event_1(Ev#mousebutton{button=3,mod=ModNoMeta}, St) ;
      Otherwise -> handle_event_1(Ev, St)
end ;

The Beauty of Synchronization

I am a big Mac fan, and use an iPhone, a Mac at work, and a Mac at home. I rely heavily on a few things to synchronize important information: .mac (shortly to become mobileme), 1Password, and Evernote. 1Password and Everynote have iPhone versions – important to me – and use the internet as a storage medium for data, while .mac is currently mostly about being an internet storage device but is also clearly just about to get an iPhone interface.