简体   繁体   English

Xcode SwiftUI 预览构建设置

[英]Xcode SwiftUI Previews build settings

I am running a pre-build script using scheme.我正在使用方案运行预构建脚本。 My script has enabled option to provide build settings from target that is being built.我的脚本启用了从正在构建的目标提供构建设置的选项。 This script also gets executed when project is built for SwiftUI Previews.当为 SwiftUI 预览构建项目时,也会执行此脚本。 I need to know inside this script if the build that is being run is regular one or for previews.如果正在运行的构建是常规构建还是用于预览,我需要在此脚本中知道。 Is there a way to do that and how?有没有办法做到这一点以及如何做到这一点?

I tried running export in the script in both scenarios but it seems that all environment variables are the same in both cases.我尝试在这两种情况下在脚本中运行export ,但似乎所有环境变量在两种情况下都是相同的。

It is possible to check ENABLE_PREVIEWS environment variable in scripts.可以在脚本中检查ENABLE_PREVIEWS环境变量。

It is YES for [Build for Previews TARGET]: [Build for Previews TARGET] 是 YES:

演示1

and NO for [Build for TARGET]: [Build for TARGET] 没有:

演示2

Tested with Xcode 13.2 / iOS 15.2使用 Xcode 13.2 / iOS 15.2 测试

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

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