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)?
What is a launch argument. In programming, we can provide different inputs to a method by passing an argument. Launch argument is a way to pass arguments to the iOS application on launch. Launch Argument has many functions, but I will use a launch argument to set UserDefaults values.
To enable launch arguments and set environment variables for your app, select your target from the Xcode toolbar and select “Edit Scheme…” On the left side of the panel, select “Run [AppName]. app”, and select the “Arguments” segment on the right side.
As of Xcode 4. x I've had to go to the Product menu, select "Edit Scheme", then select the arguments tab and add the arguments there. Also Option + clicking Run button will open this dialog.
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))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With