为什么 Xcode 构建配置的精确副本会失败? [英] Why does exact copy of Xcode Build Configuration fail?

查看:31
本文介绍了为什么 Xcode 构建配置的精确副本会失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有桥接 Swift 代码的 react-native 应用程序,它在构建、运行和存档时没有问题,Xcode 10.0 使用默认的 ReleaseDebug 构建配置.我使用 Xcode -> Product -> Archive 或播放"按钮,一切都按预期工作.太棒了!

然后今天我添加了一个新的构建配置,它与 Release 完全相同.它被命名为Release copy.我对 Debug 也做了同样的事情,它的副本是 Debug copy.

如果我尝试使用副本运行相同的 ArchiveRun 任务,这些任务将在 预编译桥接头 处失败.

/Users/whaley/dev/app/theApp/theApp-Bridging-Header.h:5:9: 错误:'React/RCTBridgeModule.h' 文件未找到#import ^产生了 1 个错误.<unknown>:0: 错误:无法发出预编译头文件 '/Users/whaley/Library/Developer/Xcode/DerivedData/theApp-ckvpglaqydwzhadbbyqoprcjvnod/Build/Intermediates.noindex/ArchiveIntermediates/theApp/PrecompiledHeaders/theApp-Bridgingswift_320079J7441HX-clang_QK5YQQC41WXA.pch' 用于桥接标题'/Users/whaley/dev/theApp/ios/theApp-Bridging-Header.h'

奇怪,在我看来,这应该是运行良好的构建配置的精确副本.

如果我切换回原始构建配置,一切都很好.原件始终有效,而副本始终失败.

我尝试了禁用预编译桥接头任务,但刚刚遇到了一个不同的,类似的错误.同样,原始构建配置在副本失败的地方工作.

我已经在使用查找隐式依赖,桥接标头命名正确,我没有使用 Cocoapods,我已经重新启动并清除了 Xcode 的Derived Data,请记住它确实正常工作.只有这些重复的构建配置会失败.

为什么会发生这种情况?我在这里错过了一步吗?这可能是 react-native 的限制,它只支持默认构建配置吗?

解决方案

当然,在我发布问题的那一刻,我设法通过 Google 找到了我需要的答案

感谢 Mateusz Klimczak 清楚地说明了问题和他们网站上的分辨率.

<块引用>

为每个新的发布版本配置的标题搜索路径添加一个条目:

$(BUILD_DIR)/Release-$(PLATFORM_NAME)/include

<块引用>

为每个新的发布版本配置为库搜索路径添加一个条目:

$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)

<块引用>

人们可能想知道为什么当我们只更改构建配置名称并且它已经为 Release 工作时需要这样做.React Native 支持开箱即用的 Debug 和 Release 构建配置,而任何其他配置都需要手动设置.

果然解决了.答案是开箱即用仅支持 ReleaseDebug,因此非标准构建配置需要额外配置.

I have a react-native app with bridged Swift code that is building, running, and archiving without issue with Xcode 10.0 with the default Release and Debug build configurations. I use Xcode -> Product -> Archive or the "Play" button and everything works as expected. Great!

Then today I added a new build configuration that is an exact duplicate of Release. It is named Release copy. I did the same for Debug as well, and its duplicate is Debug copy.

If I try to run the same Archive or Run tasks using the copies, the tasks fail at Precompile bridging header.

/Users/whaley/dev/app/theApp/theApp-Bridging-Header.h:5:9: error: 'React/RCTBridgeModule.h' file not found
#import <React/RCTBridgeModule.h>
        ^
1 error generated.
<unknown>:0: error: failed to emit precompiled header '/Users/whaley/Library/Developer/Xcode/DerivedData/theApp-ckvpglaqydwzhadbbyqoprcjvnod/Build/Intermediates.noindex/ArchiveIntermediates/theApp/PrecompiledHeaders/theApp-Bridging-Header-swift_320079J7441HX-clang_QK5YQQC41WXA.pch' for bridging header '/Users/whaley/dev/theApp/ios/theApp-Bridging-Header.h'

Odd, in my opinion, since this should be an exact copy of a build configuration that was working fine.

If I switch back to the original Build Configurations everything is fine. The originals consistently work and the copies consistently fail.

I tried disabling the Precompile bridging header task, but just encountered a different, and similar error. Again, the original build configs worked where the copies failed.

I'm already using Find implicit dependencies, the bridging header is named properly, I'm not using Cocoapods, I've rebooted and cleared Xcode's Derived Data, and please bear in mind that it does work fine normally. It's only these duplicate build configurations that fail.

Why might this be happening? Am I missing a step here? Is this perhaps a limitation of react-native and it only supports the default build configs?

解决方案

Naturally, the moment I posted my question I managed to find the answer I needed via Google

Thanks to Mateusz Klimczak for clearly illustrating the problem and resolution on their website.

Add an entry to Headers Search Paths for each new Release build configuration:

$(BUILD_DIR)/Release-$(PLATFORM_NAME)/include

Add an entry to Library Search Paths for each new Release build configuration:

$(BUILD_DIR)/Release$(EFFECTIVE_PLATFORM_NAME)

One might wonder why this is needed when we only change build configuration name and it was already working for Release. React Native supports Debug and Release build configurations out of the box, while any other configuration needs to be set up manually.

Sure enough, that fixed it. The answer is that only Release and Debug are supported out of the box, so that additional config is required for non-standard Build Configurations.

这篇关于为什么 Xcode 构建配置的精确副本会失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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