带有工作区的 Xcode 5 中的静态库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18940870/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:52:44  来源:igfitidea点击:

static libraries in Xcode 5 with workspaces

iosxcode

提问by Crystal

Is anyone having problems with static libraries with workspaces. I was looking at an old workspace where I had one normal xcode project, and one static library. It was working fine in Xcode 5. Then I wanted to add a new static lib I was working on. I added the header file in the viewcontroller I wanted to try to use it, added the static lib to my workspace, and added my static lib as one of the frameworks to link against.

有没有人对带有工作区的静态库有问题。我正在查看一个旧的工作区,在那里我有一个普通的 xcode 项目和一个静态库。它在 Xcode 5 中运行良好。然后我想添加一个我正在处理的新静态库。我在视图控制器中添加了头文件,我想尝试使用它,将静态库添加到我的工作区,并将我的静态库添加为要链接的框架之一。

#import "CTAutoLayoutUtilities/CTAutoLayoutUtilities.h"

It built fine with just the header file in place. I started typing and I saw that my static library that has some categories in it appear in the intellisense. Then I tried building, and I got an error saying that it cannot find the header file listed above. I did not change the User Header Search Paths from before when my static library was working. It still has:

它构建得很好,只有头文件就位。我开始打字,我看到我的静态库中有一些类别出现在智能感知中。然后我尝试构建,我得到一个错误,说它找不到上面列出的头文件。当我的静态库工作时,我没有更改之前的用户标题搜索路径。它仍然有:

$(BUILT_PRODUCTS_DIR) 

After that, I tried the cleaning of the project (cmd + shift + option + k). Then rebuilt, and now it's complaining that it cannot find the header files for either of my static libraries, including the one that originally worked up until now. I then removed the new static lib from the frameworks to link against, but the compiler still complains it cannot find the header file original static library that worked.

之后,我尝试了项目的清理(cmd + shift + option + k)。然后重建,现在它抱怨它找不到我的任何一个静态库的头文件,包括最初工作到现在的那个。然后我从要链接的框架中删除了新的静态库,但是编译器仍然抱怨它找不到可以工作的头文件原始静态库。

Does anyone know if something got changed in Xcode 5 or how I can get my libraries to be recognized again? Thanks.

有谁知道 Xcode 5 中是否发生了一些变化,或者我如何让我的库再次被识别?谢谢。

回答by trojanfoe

I use an Xcode Workspace all the time and haven't noticed any changes from Xcode 4 WRT include paths.

我一直在使用 Xcode 工作区,但没有注意到 Xcode 4 WRT 包含路径的任何更改。

I always do the following:

我总是做以下事情:

  • Put all projects in my ~/Sourcefolder so they are all at the same level (i.e. they are all siblings).
  • Create an Xcode project and test it before adding it to the Xcode Workspace.
  • I always manually set the Header Search Pathin the project settings for any project that uses another project; for example:

    $(PROJECT_DIR)/../OtherProject1/include
    $(PROJECT_DIR)/../OtherProject2/include
    /opt/local/include
    
  • I never have to set Library Search Pathas the binaries/libraries are always put into the same directory in the DerivedDatafolder.

  • 将所有项目放在我的~/Source文件夹中,使它们都处于同一级别(即它们都是兄弟姐妹)。
  • 创建一个 Xcode 项目并在将其添加到 Xcode 工作区之前对其进行测试。
  • Header Search Path对于使用另一个项目的任何项目,我总是在项目设置中手动设置;例如:

    $(PROJECT_DIR)/../OtherProject1/include
    $(PROJECT_DIR)/../OtherProject2/include
    /opt/local/include
    
  • 我永远不必设置,Library Search Path因为二进制文件/库总是放在DerivedData文件夹中的同一目录中。