Some favorite site feeds aggregated locally: iPhone Development RSS   Adobe Labs RSS   Macrumors RSS

Wednesday, July 8, 2009

iPhone: CorePlot

Wednesday, July 8, 2009    1 Comments

There is an open-source graphing library available for both Mac OS X and the iPhone called CorePlot. If you've gotten accustomed to the graphing packages available for Flex and Flash applications, you'll get a little tingle when you see this graphic library.

In order to integrate into your iPhone application, after checking the code out of the repository or downloading you can follow this information:

Because frameworks cannot be used in Cocoa Touch applications in the same way as on the Mac, the means of including Core Plot within an iPhone application are slightly different.

First, drag the CorePlot-CocoaTouch.xcodeproj file into your iPhone application's Xcode project (making sure that nothing's copied and the paths are relative to your project). Then go to the Targets tab in Xcode, select your application's target, and bring up the inspector. Go to the General settings page and add the CorePlot-CocoaTouch library as a direct dependency.

Core Plot is built as a static library for iPhone, so you'll need to drag the libCorePlot-CocoaTouch.a static library from under the CorePlot-CocoaTouch.xcodeproj group to your target's Link Binary With Libraries folder.

You'll also need to point to the right header location. Under your Build settings, set the Header Search Paths to the relative path from your application to the framework/ subdirectory within the Core Plot source tree. Make sure to make this header search path recursive. You need to add -ObjC to Other Linker Flags as well.

Core Plot is based on Core Animation, so if you haven't already, add the QuartzCore framework to your application project.

Finally, you should be able to import all of the Core Plot classes and data types by inserting the following line in the appropriate source files within your project:
#import "CorePlot-CocoaTouch.h

I have yet to try this out myself since I don't immediately have a need for it, but I am seeing some people encountering problems with the steps outlined. They get a EXC_BAD_ACCESS error. Perhaps this library isn't set up in it's downloaded form properly and may require some tinkering to get it rolling properly. Here is the Issues List where you can tool around to see what problems currently exist that have been commented upon.

Labels: ,