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?

4

2 回答 2

14

鉴于我是如何编写这些说明的,我可以尝试澄清您遇到问题的部分。

您需要设置标头搜索路径,以便在您包含时CorePlot-CocoaTouch.h,Xcode 知道从哪里提取它。它位于应用程序项目的 Build Settings 中的 Header Search Paths 构建设置下。它如下所示:

标头搜索路径

双击标题搜索路径的字段并弹出此弹出窗口:

标题搜索路径弹出窗口

您在此处指定的路径是从 Xcode 项目文件到安装 Core Plot 的目录的相对路径。在我的例子中,我的应用程序项目目录和 Core Plot 都位于同一个 ~/Development 目录中,因此相对路径涉及到后退一个级别 (the ../) 并转到core-plot我将框架克隆到的目录。然后,您需要指向framework存储实际框架源的子目录。

最后,选中路径左侧的小框使标题搜索递归,因此它将查找包含在此子目录中的标题。

就链接器标志而言,在这些相同的构建设置中找到您的其他链接器标志并添加-ObjC到链接器标志列表中:

ObjC 链接器标志

这是必需的,以便我们在静态库中使用的类别中的符号正确地拉入您的项目。正如我所指出的,我们过去也需要添加-all_load它来解决链接器错误,但 Xcode 4.2 中的 LLVM 修复了这个问题。这很好,因为-all_load有时会引入重复的符号并破坏针对某些第三方框架的构建。

希望这应该清除说明的特定部分。我尽我最大的努力使这些易于理解并与最新的 Xcode 版本保持同步,但也许我不够详细。如果您顺利完成了所有其余步骤,那么您应该一切顺利。

于 2012-04-21T17:01:18.723 回答
2

最简单的方法是包含 core-plot .h 文件和库二进制文件(.a 文件)。

您只需将它们全部拖到项目中即可。

干杯。

于 2012-04-21T16:35:15.280 回答