我们如何在使用 fastlane 时将 swift 编译标志添加到 `gym`

How do we add swift compile flag to `gym` when using fastlane

Office 文档页面 https://docs.fastlane.tools/actions/gym/ 中没有太多关于此的文档。

唯一提到编译标志的是:

xcargs:
Pass additional arguments to xcodebuild for the build phase. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS="-ObjC -lstdc++"

这是我们目前拥有的:

gym(options.merge(:export_xcargs => "-allowProvisioningUpdates", 
                  :export_method => "development"))

我们现在想将此标志添加到我们的构建中:

-Xfrontend -warn-long-expression-type-checking=100

我们不想像这样将它添加到 Xcode 项目文件 https://github.com/fastred/Optimizing-Swift-Build-Times 因为我们只想在使用 fastlane 的构建机器上进行此检查。

这就是我们尝试的方法:

gym(options.merge(:export_xcargs => "-allowProvisioningUpdates", 
                  :export_method => "development",
                  :xcargs => "-Xfrontend -warn-long-expression-type-checking=100"))

但是一直报这个错误:

xcodebuild: error: invalid option '-Xfrontend'

我们如何正确添加这个标志?

这有效!

gym(options.merge(:export_xcargs => "-allowProvisioningUpdates", 
                  :export_method => "development",
                  :xcargs => "OTHER_SWIFT_FLAGS='-Xfrontend -warn-long-expression-type-checking=100'"))

因为它是健身房,所以使用 export_xcargs: 而不是 xcargs: 如果您需要为标志分配一个值,请在此处查看相关答案 -