Bob De Kort
Bob De Kort

Reputation: 68

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!

Upvotes: 3

Views: 2850

Answers (1)

rodskagg
rodskagg

Reputation: 3937

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")

Upvotes: 9

Related Questions