简体   繁体   English

Xcode4工作区与静态库项目和应用程序项目

[英]Xcode4 Workspace with Static library project & application project

I'm working on a project where I'm going to eventually have a library of code that will be used by multiple applications. 我正在开发一个项目,我最终将拥有一个将由多个应用程序使用的代码库。 In reading though the documentation it sounded like creating an XCode4 workspace and 2 projects (1 library, and 1 application) was the way to go. 在阅读文档时,它听起来像创建一个XCode4工作区,并且有2个项目(1个库和1个应用程序)。

I did this and everything appeared to be working just great. 我这样做了,一切看起来都很棒。 However, today I did a bunch of work on my library project and when I run my application to test my library changes it appears to always be including an older compiled version. 但是,今天我在我的库项目上做了很多工作,当我运行我的应用程序来测试我的库更改时,似乎总是包含一个较旧的编译版本。 I'm at a loss, I added my library as a build target in my applications scheme and XCode tells me it's compiling the library, but its always linking to an old version. 我很茫然,我在我的应用程序方案中添加了我的库作为构建目标,XCode告诉我它正在编译库,但它总是链接到旧版本。

Any help is greatly appreciated. 任何帮助是极大的赞赏。 Am I missing something in how I set my workspace up? 我错过了如何设置工作区的内容吗? Is there a build step that will force linking to my newly compiled .a? 是否有一个构建步骤将强制链接到我新编译的.a? I've even tried removing the dependency, cleaning, re-adding the dependency and building my app and I still get the same results. 我甚至尝试删除依赖项,清理,重新添加依赖项和构建我的应用程序,我仍然得到相同的结果。

I ran into same problem and my solution was to add 我遇到了同样的问题,我的解决方案是添加

rm -f BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH

to the build -> pre-actions section (edit scheme, expand build and add pre-action). build -> pre-actions部分(编辑方案,扩展构建和添加预执行)。 Under Provide build settings from make sure to select your target project. Provide build settings from确保选择目标项目。 This will ensure correct env vars are configured when your script runs. 这将确保在脚本运行时配置正确的env变量。 I'm using XCode 4.5.1. 我正在使用XCode 4.5.1。

Turns out XCode was doing everything right, and I wasn't. 结果证明XCode做的一切都是正确的,而事实并非如此。 Another clean all and recompile and everything is working as expected. 另一个清理所有并重新编译,一切都按预期工作。

有关此类问题的其他信息,请参见:Xcode 4中的静态库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM