Adding launch argument for all targets

Viewed 316

I am trying to disable OS_ACTIVITY_MODE for all targets in my project. The project has multiple targets. What I can do is to go to Edit Scheme->Arguments, and to add OS_ACTIVITY_MODE = disabled for specific action (run, archive etc) but only per target. How I would do the same for all targets at once for Run action (on a project level)?

1 Answers

The simplest solution is setting the environment variable programmatically with setenv on early start of your app i.e. in main.swift file. You can add main.swift to your project if you don't have one (you should remove @UIApplicationMain from your AppDelegate class).

//  main.swift

import Foundation
import UIKit

setenv("OS_ACTIVITY_MODE", "disable", 1)

UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, nil, NSStringFromClass(AppDelegate.self))
Related