更改静态库的源需要清理并在 xcode 4 中构建

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6204364/
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-14 21:10:35  来源:igfitidea点击:

Changing the source of a static library needs clean and build in xcode 4

iphoneobjective-cxcodeios

提问by sliver

I have an iOS project that is built upon a framework project that we use in different iOS projects. The framework is included in the app project as an xcode project. The app project has a dependency on the framework's static library build target. (Similar to most open source libraries like three20)

我有一个 iOS 项目,它建立在我们在不同 iOS 项目中使用的框架项目上。该框架作为 xcode 项目包含在 app 项目中。应用程序项目依赖于框架的静态库构建目标。(类似于大多数开源库,如three20)

The problem is that if I change something in the framework source code the static library is not rebuilt when I build&run the app project.

问题是,如果我更改框架源代码中的某些内容,则在构建和运行应用程序项目时不会重建静态库。

Doing a clean followed by a build&run the changes are compiled correctly. Doing a rebuild every time I change something in the framework is not a good fix for obvious reasons.

进行清理,然后进行构建和运行,更改将被正确编译。出于显而易见的原因,每次更改框架中的某些内容时都进行重建并不是一个好的解决方案。

Is there a setting that I have to changed so that xcode is correctly identifying my framework as dirty and builds it accordingly?

是否有我必须更改的设置,以便 xcode 正确地将我的框架识别为脏框架并相应地构建它?

I'm using xcode 4.0.2

我正在使用 xcode 4.0.2

回答by sliver

This is a bug in xcode 4.0.2 (might be fixed in future version). From https://devforums.apple.com/thread/91711?start=25&tstart=0:

这是 xcode 4.0.2 中的一个错误(可能会在未来版本中修复)。来自https://devforums.apple.com/thread/91711?start=25&tstart=0

  1. Set static libraries in project, under Frameworks to: Relative to Build Products
  2. Close XCode
  3. Edit project.pbxproj and remove all the path components of the static library so that only the filname remains, like this (the important part is "path = libLibrary.a")

    A74F787413566130000D0AFC /* libLibrary.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libLibrary.a; sourceTree = BUILT_PRODUCTS_DIR; };

  1. 将项目中的静态库,在 Frameworks 下设置为:Relative to Build Products
  2. 关闭 XCode
  3. 编辑 project.pbxproj 并删除静态库的所有路径组件,只保留文件名,像这样(重要的部分是“path = libLibrary.a”)

    A74F787413566130000D0AFC /* libLibrary.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; 路径 = libLibrary.a; sourceTree = BUILT_PRODUCTS_DIR; };

回答by Rivera

Add a script step where you set your main.m file as modified

添加一个脚本步骤,在其中将 main.m 文件设置为已修改

#Force dependencies' relink
touch MyProject/main.m

回答by sergio

You are possibly missing a dependency between your target and the static library.

您可能缺少目标和静态库之间的依赖项。

In order to add a dependency:

为了添加依赖项:

  1. drag/drop the static library Xcode project on your project

    1b. add the library to your app frameworks (I understand that it's already there);

  2. select your target; show the Info pane;

  3. go to Dependencies, click on "+", then select your static lib.

  1. 将静态库 Xcode 项目拖放到您的项目上

    1b. 将库添加到您的应用程序框架(我知道它已经存在);

  2. 选择你的目标;显示信息窗格;

  3. 转到依赖项,单击“+”,然后选择您的静态库。

These instructions are valid for Xcode 3.2.x but I hope that based on this you can easily find your way out of this with Xcode 4.

这些说明适用于 Xcode 3.2.x,但我希望基于此,您可以使用 Xcode 4 轻松找到解决方法。

EDIT: For Xcode 4, check thisand this(the edited part of the question for a workaround).

编辑:对于 Xcode 4,请检查这个这个(问题的编辑部分以解决问题)。