如何根据构建配置将命令行参数传递给 Xcode

Bob*_*ort 1 xcode command-line-arguments ios

我想添加-FIRDebugEnabled参数以在 Firebase 控制台上启用调试视图,但仅当它是调试或暂存构建时。

我试过添加CommandLine.arguments.append("-FIRDebugEnabled")application didFinishLaunchingWithOptions但这似乎不起作用,所以我认为我需要在构建阶段或发布方案的预操作中添加它。但我想不通。

提前致谢!

and*_*lin 6

如果我理解正确,那么添加到方案中的启动参数仅在从 Xcode 直接将应用程序构建到设备或模拟器时设置。如果您希望在其他情况下设置 FIRDebugEnabled(以便在用户在实际设备上启动应用程序时也设置它),也许这会起作用:

var newArguments = ProcessInfo.processInfo.arguments
newArguments.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")
Run Code Online (Sandbox Code Playgroud)