Installing Core-Plot in Xcode 4.2 for iOS project
Asked Answered
I

2

10

I am trying to install Core Plot into my iOS app. I have followed the instructions on the Core Plot website but they are very brief and have no screenshots. I have pasted the instructions below and explained where I am stuck...

First, drag the CorePlot-CocoaTouch.xcodeproj file into your iPhone application's Xcode project. Show the project navigator in the left-hand list and click on your project.

Select your application target from under the "Targets" source list that appears. Click on the "Build Phases" tab and expand the "Target Dependencies" group. Click on the plus button, select the CorePlot-CocoaTouch library, and click Add. This should ensure that the Core Plot library will be built with your application.

Done!

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 the "Link Binaries With Libraries" group within the application target's "Build Phases" group you were just in.

Done!

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 (as of Xcode 4.2, -all_load does not seem to be needed, but it may be required for older Xcode versions).

I dont understand this bit!

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

Done!

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"

Done!

Is anyone able to put the instruction I am struggling with into more laymans terms?

Inmate answered 21/4, 2012 at 15:25 Comment(0)
A
14

Seeing as how I wrote those instructions, I can take a stab at clarifying the part you're having trouble with.

You'll need to set the header search path so that when you include CorePlot-CocoaTouch.h, Xcode knows where to pull that from. This is located within the Build Settings for your application project under the Header Search Paths build setting. It looks like the following:

Header search paths

Double-click on the field for the header search paths and bring up this popup:

Header search paths popup

The path you specify here is the relative path from your Xcode project file to the directory where you installed Core Plot. In my case, I had both my application project directory and Core Plot located within the same ~/Development directory, so the relative path involved stepping back a level (the ../) and going to the core-plot directory that I had cloned the framework into. You then need to point to the framework subdirectory, where the actual framework source is stored.

Finally, checking the little box to the left of the path makes the header search recursive, so it will find headers contained in subdirectories of this one.

As far as the linker flags go, find your Other Linker Flags within these same Build Settings and add -ObjC to the list of linker flags:

ObjC linker flag

This is needed so that symbols from the categories we use in the static library get pulled into your project properly. As I indicate, we used to need to add -all_load to this as well to work around a linker bug, but LLVM in Xcode 4.2 fixes this. That's good, because -all_load sometimes introduced duplicate symbols and broke building against certain third-party frameworks.

Hopefully, this should clear up that particular section of the instructions. I tried to do my best to make those easy to follow and keep them up to date with the latest Xcode versions, but perhaps I wasn't detailed enough. If you got through all the rest of the steps fine, you should be good to go.

Athens answered 21/4, 2012 at 17:1 Comment(2)
I did everything you said here, but still get CorePlot-CocoaTouch.h file not found error (I copied exact path to framework folder where CorePlot-CocoaTouch.h header is)... What else could be wrong?Stalinism
LOL. You didn't mention that: If path to framework includes any " " (white space), then all path must be in quotes like "/User/John Johnatan/Desktop/My Projects/iProject/framework/", because search paths are separated by white space. Hope this helps to someoneStalinism
R
2

The easiest way is to include the core-plot .h files and the library binary files (the .a file).

You just drag them all into the project.

Cheers.

Rositaroskes answered 21/4, 2012 at 16:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.