-
Notifications
You must be signed in to change notification settings - Fork 164
Building and testing MGTwitterEngine
MGTwitterEngine assumes the existence of several subprojects. As of September 2010, they are:
- Jonathan Wight's TouchJSON
- Lloyd Hilaiel's yajl
- Clint Shryock's OAuthConsumer
'git clone' those three projects into your top-level MGTwitterEngine repository. A swath of red filenames in the MGTwitterEngine Xcode hierarchy should turn black after each step. Here's what's next:
-
Out of the box, MGTwitterEngine expects a OAuthConsumer fork related to Jonathan George's, identifiable by a typo in its directory structure (a subfolder named "Crytpo" for "Crypto"). Clint's fork fixes the typo, so delete the "Crytpo" folder in the Xcode project, and replace it with the "Crypto" folder from your local repository.
Neither Jonathan's or Clint's OAuthConsumer forks contain the OAToken_KeychainExtensions.h/m files, so that file pair will stay red in the MGTE Xcode project. The category is available from the original OAuth Google Code project, but the three methods it adds to OAToken aren't currently used in MGTE, so they can be removed from your project without loss of functionality.
-
If you're using yajl, it also requires some adjustment. First, it needs building. If you already have cmake installed, simply './configure && make' in the yajl project directory. Otherwise you'll first have to build cmake from source, or get it from a package system such as Macports.
After you've built yajl, the MGTwitterEngine Xcode project needs to know where to find the yajl headers. MGTE's header search path hardcodes yajl's version number, and is out of date. You can either fix the search path (from, as of this writing, 1.07 to 1.0.11) or you can install yajl on your system via 'sudo make install', and replace yajl's header search path with "/usr/local/include". By using the systemwide include directory, your project won't break when yajl increments its minor version number.
Note that either way, the relevant place to fix the yajl header search path is in your target build settings, not your project build settings, and that you'll need to update the Library Search Path setting to match the Header Search Path you selected.
Note also that this gives you a version of yajl usable on the Mac, and in the iPhone Simulator, but not on an iOS device. (Anybody know how to build yajl for ARM? I spent half an hour on it, then switched to TouchJSON.)
-
Finally, you'll want to update the "C Language Dialect" in your project build settings. Change it from ANSI C to C99.
Now venture into MGTwitterEngineGlobalHeader.h
and set either YAJL_AVAILABLE
or TOUCHJSON_AVAILABLE
to 1
, depending on which library you prefer to use. The header contains some guidance. Either way, the project should at this point build with no warnings or errors.
In applicationDidFinishLaunching
of AppController.m
, add your Twitter username, consumer key, and consumer secret as NSStrings. The consumer key and consumer secret are assigned by Twitter when you register an application. Delete the password variable in two places.
The sample project assumes the use of XAuth, which if you're just starting out with MGTwitterEngine now you're probably not using. As a shortcut to working out your OAuth flow, you can retrieve your account's access token from your Twitter app dashboard. Feed the token and secret to MGTwitterEngine like so:
[twitterEngine setAccessToken: [ [ [OAToken alloc] initWithKey: @"ACCESS_TOKEN" secret: @"ACCESS_TOKEN_SECRET"] autorelease]];
Then test with an authenticated API call:
[twitterEngine getHomeTimelineSinceID:0 startingAtPage:0 count:20];
Your console should fill up with a bunch of json, corresponding to the most recent 20 entries in your timeline.