Friday, July 29, 2011

Setting up CorePlot in xcode 4

After a few frustrating hours, this is how I set up CorePlot in xcode 4:

Download the latest Core-Plot.zip file here.

We're going to do a Static Library Install:

Make a new View-Based project:
Drag the CorePlot-CocoaTouch.xcodeproj file from the finder into your project base and make sure to check the box to Copy the items into the destination group folder::

Copy the CorePlotHeaders directory to your Xcode project and make sure to check the box to Copy the items into the destination group folder:
Copy the Core Plot library to your Xcode project:
Open your apps Target Build Settings, and for Other Linker Flags include this: -ObjC -all_load
Press the "+" to add the Linker Flag, copy and paste above into the top empty space and press "Done".

Add the QuartzCore framework to the project:
Go to the "Link Binary With Libraries" tab under the "Build Phases" tab. Select the "+" button to add another linked library.
 Search for "quartz" in the search bar to quickly find the needed library then press "Add" (it will appear in your project directory). Drag the QuartzCore.framework library into the Frameworks folder:
Change your C/C++ Compiler in the project build settings to LLVM GCC 4.2 or LLVM 1.6.
In your ViewController.m file add #import "CorePlot-CocoaTouch.h"
Now you're ready to build! 

*Note:
The prefix of all core plot entities has changed from CP to CPT. So if you find a nice tutorial to work from 
that is older, you will get a Cannot find protocol declaration for 'CPPlotDataSource' or similar build error. 
So CPXTGraph needs to be changed to CPTXYGraph.

Blog Archive