xcode 为什么找不到静态库的头文件进行归档?

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

Why is a static library's header file not found for archiving?

iosxcodecompiler-errorsmbprogresshud

提问by Brenden

I can build for debugging just fine. I've triple checked that the static library is included in the build phases settings for the project. I've also tried other things like header include paths and such to no avail.

我可以为调试而构建就好了。我已经三重检查了静态库是否包含在项目的构建阶段设置中。我也试过其他的东西,比如标题包含路径等等都无济于事。

When I try to build an IPA for test flight, I get an error: #import <MBProgressHUD/MBProgressHUD.h>

当我尝试构建用于试飞的 IPA 时,出现错误: #import <MBProgressHUD/MBProgressHUD.h>

I've been able to build an IPA before, but it didn't implement/use the MBProgressHUD static library before.

我之前已经能够构建一个 IPA,但它之前没有实现/使用 MBProgressHUD 静态库。

I can include the the header and code file manually instead of statically linking it, but I prefer to know what's going on here.

我可以手动包含头文件和代码文件,而不是静态链接它,但我更想知道这里发生了什么。

Thanks.

谢谢。

PS - I used the "Static Library" instructions given https://github.com/jdg/MBProgressHUD

PS - 我使用了https://github.com/jdg/MBProgressHUD给出的“静态库”说明

采纳答案by Brenden

With the help of another SO questions(https://stackoverflow.com/a/10159481/143225) I was able to get the header file to include.

在另一个 SO 问题(https://stackoverflow.com/a/10159481/143225)的帮助下,我能够包含头文件。

Apparently, the archive build process is somehow different than the debug build process. By adding "$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts"to the "User Header Search Paths" build setting it built successfully.

显然,归档构建过程与调试构建过程有些不同。通过添加"$(BUILD_ROOT)/../IntermediateBuildFilesPath/UninstalledProducts"到“用户标题搜索路径”构建设置,它已成功构建。

I'd still like to understand why this isn't working as I expect it. I have a hunch that the project is built to auto include the header files for debug and release builds, but somehow not for archive builds. This is odd because I thought archive builds inherit from either debug or release settings from Xcode's scheme settings.

我仍然想了解为什么这不像我期望的那样工作。我有一种预感,该项目被构建为自动包含用于调试和发布构建的头文件,但不知何故不适用于存档构建。这很奇怪,因为我认为存档构建继承自 Xcode 方案设置的调试或发布设置。

Any additional info is welcome.

欢迎提供任何其他信息。

回答by Daniel Tull

By default Xcode puts the build products into $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME), this equates to build/Release-iphoneosfor instance. This is the folder that the products get built into and where the headers will get copied to.

默认情况下,Xcode 将构建产品放入$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME),这相当于build/Release-iphoneos例如。这是产品内置的文件夹以及标题将被复制到的文件夹。

When we duplicate the Release configuration to say one called "App Store", Xcode now builds into build/App Store-iphoneos. The problem is, really, that the static libraries are still being built with their Release configuration, into the Release build folder.

当我们将发布配置复制到一个名为“App Store”的配置中时,Xcode 现在会构建到build/App Store-iphoneos. 问题是,实际上,静态库仍在使用它们的 Release 配置构建到 Release 构建文件夹中。

Because the App Store config (for me, at least) is only there to easily switch between provisioning profiles, my solution is to change the "Per-configuration Build Products Path" for the App Store config to $(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)so that the App Store config also builds into the Release build folder.

因为 App Store 配置(至少对我来说)只是为了在配置文件之间轻松切换,我的解决方案是将 App Store 配置的“每配置构建产品路径”更改为,$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)以便 App Store 配置也构建进入发布构建文件夹。

回答by simplatek

Daniel Tull's answer will work, but instead of changing the 'Per-configuration Build Products Path', you can update the static library project Configurations to include a 'App Store' configuration or any other named configuration which your app target is building against, which is a duplicate of the Release configuration. This way, the static library will output it's library and headers/include files to the appropriate directory, which will be resolved by the $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) macro used in the 'Per-configuration Build Products Path'; and walllaaaaa...the public library headers can now be resolved properly by Xcode. So to sum it up, if you have an 'App Store' named configuration in your app's target and your linking against a static library which exports headers, make sure the static library project also includes the 'App Store' configuration and you will be one happy camper.

Daniel Tull 的回答将起作用,但您可以更新静态库项目配置以包含您的应用程序目标正在构建的“App Store”配置或任何其他命名配置,而不是更改“按配置构建产品路径”是发布配置的副本。这样,静态库会将它的库和头文件/包含文件输出到适当的目录,这将由“每配置构建产品路径”中使用的 $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 宏解析'; 和 walllaaaaa...公共库标题现在可以由 Xcode 正确解析。总而言之,如果您的应用程序目标中有一个名为“App Store”的配置,并且您链接到一个导出标头的静态库,