XCode 4.2 和使用静态库导致问题 [英] XCode 4.2 and Using a Static Library Causing Problems

查看:26
本文介绍了XCode 4.2 和使用静态库导致问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像这里的许多其他人一样,我在我的 XCode 工作区中使用库时遇到问题.这个想法是我有我的主要项目(MyApp)和两个库(lib1lib2),它们在代码被添加到工作区之后最终确定.

作为背景,lib1依赖于lib2,因为为了使用lib2需要实现一些协议.MyApp 依赖于两者.我尝试遵循 Apple 指南,这意味着我想要的很简单.在那之后,我关注了几乎所有在我搜索中出现的 SO 帖子(谷歌搜索了 2 天),以及许多其他声称有解决方案的博客和帖子,其中许多是特定于 XCode 3 的.

然而,我的项目没有构建.我在 OS 10.6 上使用 Xcode 4.2(升级到 Lion 不是一种选择).是否有关于如何创建库项目并在应用程序中使用该库的简单教程.

我在写这个问题时遇到了这个答案(这个问题和我有同样的错误),我将调查,但我已经达到了复制源文件的地步,只是为了让演示工作.

更新:

这是出现的问题列表.当它们出现时我会添加更多:

  • **找不到选项-L/Users/myhomedir/iphoneprojects/MyApp/../BLProfile/build/Release-iphoneos"的目录**

解决方案

这里是如何创建静态库和使用它的项目.

步骤 1: 创建工作区:文件 > 新建 > 工作区.这不是强制性的,但它有助于组织项目.

第 2 步: 创建一个静态库项目:文件 > 新建 > 项目 > 框架和库 > Cocoa Touch 静态库.我们称之为MyLib.

步骤 3: 创建应用程序项目:文件 > 新建 > 项目 > 应用程序> 空应用程序,或任何其他应用程序模板.让我们将此项目称为 MyApp.如果您将项目放在不同的文件夹中,则可能需要使用不同的路径.

现在您的工作区中有以下项目.

步骤 4: 配置应用程序,使其找到库的 .h 文件.为此,请添加父文件夹 "../" 并选中 递归 复选框.

第 5 步:将应用链接到库.

Like many others here SO, I am having issues using libraries in my XCode workspace. The idea is I have my main project (MyApp) and two libraries (lib1 and lib2) which were added to the workspace after the code was finalized.

For background, lib1 is dependent on lib2, since there are some protocols that need to be implemented in order to make use of lib2. MyApp is dependent on both. I have tried following the Apple guides, which implies what I would like to is simple. After that, I have followed pretty much every post here on SO that has come up in my searches (2 days worth of Googling), plus many other blogs and posts that claim to have solutions, many of which are XCode 3 specific.

Yet, my project does not build. I am using Xcode 4.2 on OS 10.6 (upgrading to Lion is not an option). Is there a simple tutorial to follow on how to create a library project, and use this library in an application.

I came across this answer while writing this question (where the question had the same error I had), which I will look into, but I have reached the point of copying source files over just to get a demo working.

UPDATE:

Here is list of issues that have come up. I will add more when they arise:

  • **directory not found for option '-L/Users/myhomedir/iphoneprojects/MyApp/../BLProfile/build/Release-iphoneos'**

解决方案

Here is how to create a static library and a project that use it.

Step 1: Create a workspace: File > New > Workspace. This is not mandatory but it helps organize the projects.

Step 2: Create a static library project: File > New > Project > Framework and Library > Cocoa Touch Static Library. Lets call it MyLib.

Step 3: Create an Application Project: File > New > Project > Application> Empty Application, or any other application template. Lets call this project MyApp. If you placed the projects in different folders, you may have to use a different path.

Now you have the following Projects in the workspace.

Step 4: Configure the app so that it finds the .h files of the library. To do that, add the parent folder "../" and check the recursive checkbox.

Step 5: Link the app to the library.

这篇关于XCode 4.2 和使用静态库导致问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆