Compiling MGTwitterEngine for the iPhone using Xcode

Surprisingly there are not a lot of options for Objective-C Twitter libraries. In fact there are exactly two options: MGTwitterEngine and Canary (which is actually a “full-fledged client”). The choice looks clear, use MGTwitterEngine or deal with XML directly (yuck!).

MGTwitterEngine does not implement the entire Twitter API but it does implement the most important things like updating status, retrieving your friend’s timeline, etc. For my current uses, that’s all I need.

It took me a little bit of effort to get MGTwitterEngine compiling and running correctly:

  1. Checkout the project from subversion (svn co http://svn.cocoasourcecode.com/MGTwitterEngine-1.0.8/).
  2. Delete files that aren’t needed: .svn, AppController.h, AppController.m, English.lproj, Info.plist, main.m. Optionally delete README.txt, TODO. Leave alone Source Code License.rtf.
  3. Add the remaining sources to your project.
  4. Change USE_LIBXML to 1 (instead of 0) to use libxml for a smaller footprint.
  5. In your target, within the general tab add libxml2.dylib.
  6. In your target, within the build tab, add to “header search path”: “${SDKROOT}/usr/include/libxml2″. Make sure you’ve selected the recursive checkbox.

If you are getting an error saying “error: libxml/xmlreader.h: No such file or directory”, make sure you’ve completed the last 2 steps listed above.

A working example can be found on an early commit to my iPhone app hosted on github.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Bloglines
  • Google Bookmarks
  • Technorati
  • TwitThis
Tags: , , , ,