简体   繁体   中英

How to pass command line argument to Xcode based on build configuration

I would like to add the -FIRDebugEnabled argument to enable the debug view on the Firebase console but only when it is a debug or staging build.

I have tried adding CommandLine.arguments.append("-FIRDebugEnabled") in application didFinishLaunchingWithOptions but this does not seem to work, so I think I need to add it during a Build phase or a pre-action in the release scheme. But I can't figure it out.

Thanks in advance!

If I understand things correctly, launch arguments added to a scheme are only set when building the app from within Xcode directly to a device or the simulator. If you wish to set FIRDebugEnabled in other cases (so that it's also set when the user launches the app on the actual device), maybe this will work:

var newArguments = ProcessInfo.processInfo.arguments
newArguments.append("-FIRDebugEnabled")
ProcessInfo.processInfo.setValue(newArguments, forKey: "arguments")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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