I was surprised by the lack of details on this topic so I decided to post my experiences with getting Evernote’s API setup in an iPhone application.
Note: Don’t forget to ask for an Evernote API key.
Steps for geting Evernote API compiling for the iPhone.
1. Grab thrift cocoa runtime:
$> svn co http://svn.apache.org/repos/asf/incubator/thrift/trunk/lib/cocoa/src/ thrift-cocoa
2. Grab latest Evernote API from http://www.evernote.com/about/developer/api
$> wget http://www.evernote.com/about/developer/api/evernote-api-1.xx.zip
3. Unzip Evernote API
$> unzip evernote-api-1.xx.zip
4. Go into the evernote cocoa source directory and replace every occurance of <Cocoa/Cocoa.h> with <UIKit/UIKit.h>
$> cd evernote-api-1.13/src/cocoa $> perl -pi -e 's/<Cocoa\/Cocoa.h>/<UIKit\/UIKit.h>/g' *.h $> perl -pi -e 's/<Cocoa\/Cocoa.h>/<UIKit\/UIKit.h>/g' *.m
5. Open XCode and add a ‘3rdParty’ group with the group “Evernote” beneath it
6. From the 3rdParty group click “Add existing files” and select the thrift-cocoa folder.
7. Expand the thrift-cocoa folder and delete the references to the folder server and everything contained within it.
8) Expand the transport folder and delete TSocketClient.m & TSocketClient.h (Evernote does not appear to need these and they won’t build with the iPhone SDK.)
9. From the “Evernote” group click “Add existing files” and select the cocoa folder under evernote-1.xx/src/cocoa
10. Try to build the system. I am using 1.13 and for whatever reason the cocoa is borked and needs some massaging. If you get errors like ‘EDAM_MIME_TYPES’ undeclared (first use in this function) then you have two choices. Install boost and thrift idl and run the thrift files in evernote-api-1.xx/src/thrift through thrift and it should generate good files otherwise you need to look at the errors and determine if you can fix them using some simple replacements as I have done below…
# Replaces the erroneous EDAM_ with EDAMEDAM_ $> perl -pi -e 's/ EDAM_/ EDAMEDAM_/g' EDAMLimits.m $> perl -pi -e 's/ EDAM_/ EDAMEDAM_/g' Types.m $> perl -pi -e 's/ EDAM_/ EDAMEDAM_/g' UserStore.m # But this breaks the function definitions so I refix them here. $> perl -pi -e 's/\+ \(int32_t\) EDAMEDAM_/\+ \(int32_t\) EDAM_/g' EDAMLimits.m $> perl -pi -e 's/\+ \(NSString \*\) EDAMEDAM_/\+ \(NSString \*\) EDAM_/g' EDAMLimits.m $> perl -pi -e 's/\+ \(NSSet \*\) EDAMEDAM_/\+ \(NSSet \*\) EDAM_/g' EDAMLimits.m $> perl -pi -e 's/\+ \(NSString \*\) EDAMEDAM_/\+ \(NSString \*\) EDAM_/g' Types.m $> perl -pi -e 's/\+ \(int16_t\) EDAMEDAM_/\+ \(int16_t\) EDAM_/g' UserStore.m
Your mileage will vary. 😉